Reputation: 5920
I m trying to image upload to server. Here is my code:
try
{
fuImage.SaveAs(Server.MapPath("..\\App_Upload\\Product\\") + fileName);
}
catch (Exception exc)
{
dvMessage.InnerHtml = WebUtil.CreateAlert(WebUtil.NotifyMessage.Warning,"İşlem Başarısız!", "Resim Dosyası eklerken hata oluştu. HATA:" + exc.Message);
return;
}
It works in my local computer but on server, it returns Access to the path 'D:\inetpub\karahanresim.com\test.karahanresim.com\App_Upload\Product\2012722165754.jpg' is denied.
Do you know any suggestion for me?
Upvotes: 0
Views: 903
Reputation: 70513
Remember IIs caches permissions. If you change permissions on the server you have to reset IIs
C:\> iisreset
Upvotes: 0
Reputation: 1038720
You will have to grant sufficient permissions to the account that your site is configured to run under in IIS so that it can write to this folder.
And by the way I would rewrite your code like so:
var productPath = Server.MapPath("~/App_Upload/Product");
fuImage.SaveAs(Path.Combine(productPath, fileName));
Upvotes: 1