This is my code:
string path = Server.MapPath("~/") + "\\Img\\";
string[] validext = { ".jpg", ".png", ".gif" };
string ext = System.IO.Path.GetExtension(FileUpload1.PostedFil开发者_Python百科e.FileName);
long size = FileUpload1.PostedFile.ContentLength / 1024;
string filename = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
if (filename.Length > 10)
{
string[] str2 = filename.Split('.');
filename = filename.Substring(0, 2);
filename += '.';
filename += str2[str2.Length - 1];
}
while (System.IO.File.Exists(filename))
filename = "1" + filename;
if (ext != "")
FileUpload1.PostedFile.SaveAs(path + filename);
but when I choose a file and click on the send button my website has the following error.
Access to the path 'C:\inetpub\vhosts\pouyagroup.ir\httpdocs\Img\s.jpg' is denied.
It works well on localhost.
What is the problem?
精彩评论