开发者

problem with file upload in asp access to directory is denied

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜