文件上载的时候提示上载的路径拒绝访问,上载路径的文件夹我已经设置成everyone完全控制
一下为主要代码:
<table>
<tr>
<td align="left" width="12%" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="up" Runat="server">文件上载:</asp:Label>
<INPUT type="file" size="50" NAME="File">
<asp:Button Runat="server" Text="开始上传" ID="Button1"></asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="this.form.reset()" type="button" value="重置(ReSet)">
<asp:Label id="Label2" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px"
BorderStyle="None" BorderColor="White"></asp:Label>
</td>
</tr>
<tr>
<asp:Label id="strStatus" runat="server" Font-Names="宋体" Font-Bold="True" Font-Size="9pt" Width="500px"
BorderStyle="None" BorderColor="White"></asp:Label>
</tr>
</table>后台(C#):private Boolean SaveImages()
    {
      ///'遍历File表单元素
      HttpFileCollection files  = HttpContext.Current.Request.Files;      /// '状态信息
      System.Text.StringBuilder strMsg = new System.Text.StringBuilder();
      strMsg.Append("上传的文件是:<hr color=red>");
      try
      {
        for(int iFile = 0; iFile < files.Count; iFile++)
        {
          ///'检查文件扩展名字
          HttpPostedFile postedFile = files[iFile];
          string fileName, fileExtension;
          fileName = System.IO.Path.GetFileName(postedFile.FileName);
          if (fileName != "")
          {
            fileExtension = System.IO.Path.GetExtension(fileName);
            strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>");
            strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
            strMsg.Append("上传文件的文件名:" + fileName + "<br>");
            strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
            ///'可根据扩展名字的不同保存到不同的文件夹
        
            postedFile.SaveAs(("//\\10.1.30.41\\software\\") + fileName);
          }
        }
        strStatus.Text = strMsg.ToString();
        return true;
      }
      catch(System.Exception Ex)
      {
        strStatus.Text = Ex.Message;
        return false;
      }    }

解决方案 »

  1.   

    postedFile.SaveAs(("//\\10.1.30.41\\software\\") + fileName);跨网不可以上传的!
      

  2.   

    给文件夹Asp.net写入权限测试一下
      

  3.   

    我已经把上载的目的文件设置成了everyone完全控制,权限应该是够用的,楼上说的“给文件夹Asp.net写入权限测试一下”是什么意思,没有看明白???
      

  4.   

    \\10.1.30.41\\software,你是保存到另外一台机子上去么??
    IIS估计没有这么大的权限吧.你先试试本地可以不
    然后在web.config设置一个帐号...另外一台机子加一个相同帐号..
    然后程序看看怎么写吧..只给个思路.具体我也不会.
      

  5.   

    很抱歉!\\10.1.30.41\\software没有仔细看你的路径,IIS是没有这么大的权限的
    还是从你的程序设计上着手考虑吧。另外不需要everyone完全控制,权限太大了
    Asp.net写入权限就够了
      

  6.   

    web.config里
    <!-- 设置可接受的最大字节数 -->
    <httpRuntime maxRequestLength="40960" executionTimeout="36000" > 
    </httpRuntime>