944,133 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 20219
  • ASP.NET RSS
Apr 12th, 2006
0

Uploading files Access Denied Error

Expand Post »
Hi all,
I am very happpy to return back again to you.
This time i have a critical problem about uploading files on the server by asp.net.
I choosed the HTML control "File" and Make it run as server control , and got its file name by the statement
string fname=File1.PostedFile.FileName
then i want to save it on the server Hard Disk so i used the statement :

try
{
File1.PostedFile.SaveAs(Server.MapPath("Project\\"+ff));
}
catch
{
Directory.CreateDirectory(Server.MapPath("Project\\"+ff));
File1.PostedFile.SaveAs(Server.MapPath("Project\\"+ff));
}


When running the page the following exception occured
Access to the path "c:\inetpub\wwwroot\Cubicle\Project\MyFile.doc" is denied.
which "c:\inetpub\wwwroot\Cubicle\" is my project directory (my project name is Cubicle)
Note : i configured the IIS options to be write ,read, and Directory browsing . and the problem is still exist .
Can any one help me ?
Thank You.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
web developer is offline Offline
36 posts
since Mar 2006
Apr 12th, 2006
0

Re: Uploading files Access Denied Error

try
ASP.NET Syntax (Toggle Plain Text)
  1. {
  2. File1.PostedFile.SaveAs(Server.MapPath("\\Project")+"\\" + ff);
  3. }
  4. catch
  5. {
  6. try
  7. {
  8. Directory.CreateDirectory(Server.MapPath("Project"));
  9. File1.PostedFile.SaveAs(Server.MapPath("Project")+"\\" + ff);
  10. }
  11. catch(Exception exp)
  12. {
  13. string message = exp.Message;
  14. }
  15. }
Last edited by campkev; Apr 12th, 2006 at 6:59 pm. Reason: added code tags
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Apr 13th, 2006
0

Re: Uploading files Access Denied Error

are u sure u entered in the form tag enctype="multipart/form-data"?
Reputation Points: 10
Solved Threads: 15
Junior Poster in Training
silviuks is offline Offline
95 posts
since Apr 2006
Apr 13th, 2006
0

Re: Uploading files Access Denied Error

Thank you All
i have solved the problem from IIS Configuration by right click on the project name (from IIS window) and then All Tasks -> Permission Wizard and select read,write permissions.
it is solved now . and was no problem with the code .
Thank you again .
Reputation Points: 10
Solved Threads: 0
Light Poster
web developer is offline Offline
36 posts
since Mar 2006
Nov 29th, 2007
0

Re: Uploading files Access Denied Error

hello all, I'm new here
I try to follow everything in Google search to resolve my problem
but nothing done
I'm trying to upload file in asp.net
the same error of " Access to the path 'c:\inetpub\wwwroot\aa' is denied. " repeated every time I try to upload
so how to manage this problem ? I put all privileges to aspnet user and also to all user , but nothing changed
any help pleas , please
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ab_dc is offline Offline
1 posts
since Nov 2007
Nov 29th, 2007
0

Re: Uploading files Access Denied Error

Click to Expand / Collapse  Quote originally posted by ab_dc ...
hello all, I'm new here
I try to follow everything in Google search to resolve my problem
but nothing done
I'm trying to upload file in asp.net
the same error of " Access to the path 'c:\inetpub\wwwroot\aa' is denied. " repeated every time I try to upload
so how to manage this problem ? I put all privileges to aspnet user and also to all user , but nothing changed
any help pleas , please
There are two places the permissions need to fixed at for upload to work:
1. IIS on the folder you want to upload you need to check the allow write check box
2. right click the actual folder in file explorer and allow everyone to write to this folder. Please remember the web user is a low permission user IIS_ somthing.
Reputation Points: 10
Solved Threads: 4
Newbie Poster
shaulf is offline Offline
18 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: discussion forum
Next Thread in ASP.NET Forum Timeline: (Please Help :o( ) Config Error: "Login failed for user 'STS-SYNMAC\userName'."





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC