mnaftal
mnaftal

Reputation: 1

FileUpload error in the server

hi I have a FileUpload and I save a picture and this is the error

Access to the path 'D:\Hosting\0000000\html\images\APgt_logo.jpg' is denied.

an my local is working well whats the problem?

this is the code

new_row["Product_imag"] = FileUpload1.FileName.ToString();
FileUpload1.SaveAs(Server.MapPath("/images/"+ FileUpload1.FileName.ToString()));

Upvotes: 0

Views: 155

Answers (2)

ChrisLively
ChrisLively

Reputation: 88044

This is a permissions problem on your web server.

When you run the project locally, the local web server is executing using your permissions which has write access to the directory in question.

When running on the server, the user the app pool is executing under does not have permission to write to the directory. This is normal as it usually shouldn't.

You might ask this over at serverfault.com to get some good recommendations on how to do this in a secure manner.

Upvotes: 1

Mikael Östberg
Mikael Östberg

Reputation: 17146

The user that is running the Web Service process (ie w3wp.exe) doesn't have sufficient rights on the folder you are trying to write to.

Either you have to set write rights in IIS, or you have to adjust the security in the file system. Or both.

You need to provide more information if you want help with that.

Upvotes: 3

Related Questions