上传发生错误!原因System.UnauthorizedAccessException
做的网站后台上传图片
服务器显示这个错误
上传发生错误!原因System.UnauthorizedAccessException: 对路径“D:\wwwroot\test\web\img\newspic\turnpic4.jpg”的访问被拒绝。 在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) 在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) 在 System.IO.FileStream..ctor(String path, FileMode mode) 在 System.Web.HttpPostedFile.SaveAs(String filename) 在 management_newpic_add.fileupload_Click(Object sender, EventArgs e)[/color]
服务器那边给了我只读和写入的权限(完全控制,读取修改这些到是没勾上)turnpic4.jpg是我现在上传的图片
string filename = FileUpload1.PostedFile.FileName;//得到完整路径 客户端路径
string serverpath = Server.MapPath("../img/newspic/"+System.IO.Path.GetFileName(filename)) ;//服务器上要保存 的路径
FileUpload1.PostedFile.SaveAs(serverpath);
<location path="management">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
[解决办法]
对路径“D:\wwwroot\test\web\img\newspic\turnpic4.jpg”的访问被拒绝。
这不是说了,没权限,你要设置asp.net和network用户的读写权限
[解决办法]
是ASPNET用户的读写权限
http://www.sudu.cn/info/html/edu/20071224/12536.html