Shelly
Shelly

Reputation: 301

Access to path is denied when trying to upload file

Access to the path D:\Hosting\10983309\html\sunithahome\images\GallerySunithaHA\IMG_7162.jpg is denied. I have find this error when I try to upload an Image in GallerySunitha Folder.

How can I solve this problem?

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 = "";
    }

Upvotes: 0

Views: 3206

Answers (1)

Anant Dabhi
Anant Dabhi

Reputation: 11104

Tt seems you are having problem after hosting your web application on godaddy you need to give read-write rights to foler images to save file in folder

you need to use GoDaddy's configuation panel to grant write access to that folder.

for more info File Upload Permission denied Godaddy Shared hosting

Upvotes: 5

Related Questions