小编She*_*lly的帖子

尝试上传文件时拒绝访问路径

D:\Hosting\10983309\html\sunithahome\images\GallerySunithaHA\IMG_7162.jpg拒绝访问该路径.当我尝试在GallerySunitha文件夹中上传图像时,我发现此错误.

我怎么解决这个问题?

if (FileUploadGlry1.HasFile)
    {
        string FileName = Path.GetFileName(FileUploadGlry1.PostedFile.FileName);
        FileUploadGlry1.SaveAs(Server.MapPath("~/images/GallerySunithaHA/" + FileName));
        con.Open();
        query = "insert into Gallery(ImageName,Caption,ImagePath) values(@Iname,@Cap,@Ipath)";
        Sqlcmd = new SqlCommand(query, con);
        Sqlcmd.Parameters.AddWithValue("@Iname", FileName);
        Sqlcmd.Parameters.AddWithValue("@Ipath", "~/images/GallerySunithaHA/" + FileName);
        Sqlcmd.Parameters.AddWithValue("@Cap", TextBoxGalleryCaption1.Text);
        Sqlcmd.ExecuteNonQuery();
        PanelViewImage.Visible = true;
        con.Close();
        TextBoxGalleryCaption1.Text = "";
    }
Run Code Online (Sandbox Code Playgroud)

c# asp.net

0
推荐指数
1
解决办法
2388
查看次数

标签 统计

asp.net ×1

c# ×1