我试图将图像文件上传到服务器,它给我一个错误如何访问共享主机空间上的文件夹?
"System.UnauthorizedAccessException: Access to the path 'D:\Hosting\234344\html\Testingfiles\upload\813.jpg' is denied.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)"
中的HttpHandler我:
HttpPostedFile file = context.Request.Files["Filedata"];
string usr_id = context.Request.Form["usr_id"];// gets the JSON data from the request
string strPath = context.Server.MapPath(("/Testingfiles/upload/") + file.FileName);
string ext = Path.GetExtension(strPath);
if (ext.Equals(".jpg") || ext.Equals(".jpeg") || ext.Equals(".png"))
{
file.SaveAs(strPath);
context.Response.Write("Image uploaded successfully");
}
我到底错在这里做什么?
我给了应用程序池组的权限,即IWPG(用户名)。它在parellel plesk 12.0.8中运行。你的回答给了我一个很好的理由。谢谢 – 2015-05-28 17:49:05