Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
2.78/5 (3 votes)
See more:
we are try to upload some file from file upload control from client to server. this code is proper working in local machine. and upload files. but after hosting it gives following error:

Error: Access to the path G:PleskVhostsexamcart.inhttpdocsDochindi.jpg is denied.

we are using asp.net 4.0. if there is any permission problem. then how we provide permission on remote server or iis.

What I have tried:

C#
if (FileUpload1.HasFile)
{
    FileUpload1.SaveAs(Server.MapPath("~/Doc/") + TxtFileName.Text.Trim() + 
    System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName));
}


we also tried following. but generate same error:

C#
if (FileUpload1.HasFile)
{
    FileUpload1.SaveAs(Server.MapPath("~//Doc//") + TxtFileName.Text.Trim() + 
    System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName));
}
Posted
Updated 2-Jun-17 9:39am
v2
Comments
F-ES Sitecore 2-Jun-17 8:35am    
The error is fairly self-explanatory, you need write access to that folder (I'm assuming the path is ok and the slashes have been removed from what you posted somehow). Either set the permissions in your control panel or get your webhost to do it.
kantagrawal 3-Jun-17 2:29am    
how to provide the write access permission. because my hosting is on godaddy. is there any procedure to change permission by myself. or will be changed by godaddy.

1 solution

You need to setup an account that has permissions and then change the account on the Application Pool in IIS to use the new account. That is what account your code is running as.
 
Share this answer
 
Comments
kantagrawal 3-Jun-17 2:24am    
My Hosting is on godaddy. so how can i to change the iis server setting.
ZurdoDev 3-Jun-17 10:08am    
By contacting them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900