日期:2014-05-17  浏览次数:20457 次

上传发生错误!原因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>


management这个文件夹对匿名用户拒绝访问
其他都可以
但是图片的文件夹(名为img)还有专门用于文件下载的文件夹(upfile)不可访问
不知是程序的问题还是?
请各位帮忙看一下,谢谢。
服务器 上传文件