郁闷 我在网上找了个上传的代码 保存路径到数据库  但是 运行出错:但是在另外一台机器上就能上传成功 
它提示 错误:
未能找到文件“20091017339.jpg”。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.FileNotFoundException: 未能找到文件“20091017339.jpg”。 源错误: 
行 34:        path = "..\\file\\" + fileName;                      //设置附件上传到的服务器路径 
行 35:        FileInfo fileInfo = new FileInfo(str);                //获取文件信息 
行 36:        long fileSize = (fileInfo.Length / 1024) / 1024;      //获取文件大小 
行 37:        if (fileSize > 10)//控制文件大小不能超过10M 
行 38:        { 
 

解决方案 »

  1.   

    path = "..\\file\\" + fileName;  这是什么路径,换成
    Server.MapPath("..\\file\\") + fileName 看看。
      

  2.   

    还是错误啊:
    编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0201: 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句源错误: 行 32:         //获取附件名称 
    行 33:         String fileName = str.Substring(str.LastIndexOf("\\") + 1);
    行 34:         Server.MapPath("..\\file\\") + fileName;               //设置附件上传到的服务器路径
    行 35:         FileInfo fileInfo = new FileInfo(str);                 //获取文件信息
    行 36:         long fileSize = (fileInfo.Length / 1024) / 1024;       //获取文件大小
     源文件: e:\ProjectManager\fileManager\UpMaterial.aspx.cs    行: 34 
      

  3.   

    文件路径有问题,
    LZ可以用File来判断一下你指定的路径是否能指定到一个文件上
      

  4.   

    图片文件上传:
        string name = FileUpload1.FileName;
        string size = FileUpload1.PostedFile.ContentLength.ToString();
        string type = FileUpload1.PostedFile.ContentType;
        string type2 = name.Substring(name.LastIndexOf(".") + 1);
        string ipath = Server.MapPath("upimg") + "\\" + name;
        string fpath = Server.MapPath("Upfile") + "\\" + name;
        string wpath = "upimg\\" + name;
        if (type2 == "jpg" || type2 == "gif")
        {
          Image1.Visible = false;
          if (!Directory.Exists(Server.MapPath("upimg") + "\\"))
          {
            Directory.CreateDirectory(Server.MapPath("upimg") + "\\");
          }
          FileUpload1.SaveAs(ipath);
          Image1.ImageUrl = wpath;
          Label1.Text = "文件名" + name + "<br>文件大小" + size + "<br>文件类型" +
            type2 + "<br>文件后缀" + ipath + "<br>文件虚拟路径" + wpath;
        }
        else
        {
          Image1.Visible = false;
          if (!Directory.Exists(Server.MapPath("Upfile") + "\\"))
          {
            Directory.CreateDirectory(Server.MapPath("Upfile") + "\\");
          }
          FileUpload1.SaveAs(fpath);
          Label1.Text = "文件名" + name + "<br>文件大小" + size + "<br>文件类型" +
          type2 + "<br>文件后缀" + ipath + "<br>文件虚拟路径" + wpath;
        }
      

  5.   

    我已经测试了 在ie6 ie7 上能正常上传!ie8上面就报错!
      

  6.   

    不太可能吧 这个还和ie有关系  还是在查查上传路径吧  
    如果你非要觉得是ie8引起的  就在head中加入
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    如果这样没解决就证明和ie无关