Click here to Skip to main content
15,884,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello
I have developed a webpage where i need to upload a image of user . I wrote code for that and tested it on local server. But when i uploaded it on server it giving exception

System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\pspl-it.com\site1\projects\SBI - Copy.jpg' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at ....
And my code is


C#
string filename =System.IO.Path.GetFileName(Fileimage.PostedFile.FileName);
      Fileimage.SaveAs(Server.MapPath("projects/") + filename);

Please suggest me.
Thanx in advance.
Posted
Comments
[no name] 27-Sep-14 10:59am    
http://msdn.microsoft.com/en-us/library/ms524632(v=vs.90).aspx
Narendra Singh 27-Sep-14 11:04am    
Will u please explain my mistake in code i able to get your point . Please sir
[no name] 27-Sep-14 11:08am    
Why don't you go read the documentation for yourself? It explains it to you plain as day.

1 solution

This is due to the permission issue for that folder in server.

Please assign proper permission to the folder by going to its properties. Search the issue in Google for more information.
 
Share this answer
 
Comments
Narendra Singh 27-Sep-14 11:37am    
I have done this but still same
Anthony Mushrow 27-Sep-14 12:17pm    
Are you sure the permissions are set for the correct user? I'm not sure which user the server would be running as, but it's something you should check.
Narendra Singh 27-Sep-14 12:19pm    
yeah i am sure for more you can check it
bank.pspl-it.com/default3.aspx
visit this link and please tell me the error
Then File might not have the permission.

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