Reputation: 1
i am trying to upload image and store it in file system in asp.net using c#. i am using this code
if (FileUpload1.HasFile)
{
if ((FileUpload1.PostedFile.ContentType == "image/jpeg") ||
(FileUpload1.PostedFile.ContentType == "image/png") ||
(FileUpload1.PostedFile.ContentType == "image/tmp") ||
(FileUpload1.PostedFile.ContentType == "image/gif"))
{
if (Convert.ToInt64(FileUpload1.PostedFile.ContentLength) < 10000000)
{
string filename = Label1.Text;
FileUpload1.SaveAs(Server.MapPath("productImage\\" + ddlproductId.Text + "\\" + filename + ".jpg"));
}
}
}
it actually work fine in my computer but while i am uploading it on server it get some error. please help me. thanking you.
Upvotes: 0
Views: 1359
Reputation: 15797
Sounds like a permissions problem. You'll want to change the security of that folder on the web server and ensure NETWORK SERVICE
has Write
permissions. Or, if you have an older server, it will be ASPNET
.
Upvotes: 2