“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------D:\hosting\wwwroot\bio-star_cn\htdocs\img\\qichi\\productPic\\B2008-5-8_23_40.gif 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.FileNotFoundException: D:\hosting\wwwroot\bio-star_cn\htdocs\img\\qichi\\productPic\\B2008-5-8_23_40.gif源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
[FileNotFoundException: D:\hosting\wwwroot\bio-star_cn\htdocs\img\\qichi\\productPic\\B2008-5-8_23_40.gif]
   System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) +205
   System.Drawing.Image.FromFile(String filename) +7
   news.connection.MakeThumbnail(String originalImagePath, String thumbnailPath, Int32 width, Int32 height, String mode) in e:\renke3\class\conn1.cs:252
   news.manager.admin_addinfoP.Submit1_ServerClick(Object sender, EventArgs e) in e:\renke3\manager\admin_addinfop.aspx.cs:302
   System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e) +108
   System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292 
下面是我写的上传图片代码:
#region 上传图片文件

try
{
//保存路径
System.IO.Directory.CreateDirectory(Server.MapPath("../img")+@"\\qichi\\productPic\\");
fileBPic.PostedFile.SaveAs(Server.MapPath("../img")+@"\\qichi\\productPic\\"+"B"+DateTime.Now.GetDateTimeFormats()[40].Replace(' ','_').Replace(':','_')+fileBName);
}
catch(Exception ee)
{
Response.Write("<script language=javascript>alert('图片上传错误。'+ee.Message);");
Response.Write("</script>");
} #endregion

解决方案 »

  1.   

    /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpLoad_Click(object sender, EventArgs e)
        {
            try
            {
                string test = Server.MapPath("ImageFiles/" + DateTime.Now.ToString("yyyy-MM-dd"));  //用来生成文件夹
                if (!Directory.Exists(test))
                {
                    Directory.CreateDirectory(test);
                }
                if (FileUpload1.PostedFile.FileName != "")
                {
                   string  imgname = FileUpload1.PostedFile.FileName;
                   string imgType = imgname.Substring(imgname.LastIndexOf(".") + 1);
                   string quanname =DateTime.Now.ToString("yyyyMMddHHmmss")+imgname.LastIndexOf("\\")+"."+imgType ;
                   if ("gif" != imgType && "jpg" != imgType && "GIF" != imgType && "JPG" != imgType)
                    {
                        Response.Write("<script>alert('请选择gif,jpg格式的文件!');</script>");
                        return;
                    }
             
                    string imgurl = "ImageFiles/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + quanname;
                     FileUpload1.PostedFile.SaveAs(Server.MapPath(imgurl));
                    }
                else
                {
                    Response.Write("<script>alert('请选择文件上传!');</script>");
                }
            }        catch (Exception ex)
            {
                throw ex;
            }
        }
      

  2.   

    D:\hosting\wwwroot\bio-star_cn\htdocs\
                                          \img\qichi\productPic\B2008-5-8_23_40.gif 
                                          \manager\上传文件的文件.
    上面代码有个明显的错误做如下改正,但还是报同样的错.苦恼,请高手帮忙解答!
     #region 上传图片文件
                    
                        try
                        {
                            //保存路径
                            System.IO.Directory.CreateDirectory(Server.MapPath("../img")+@"\qichi\productPic\");
                            fileBPic.PostedFile.SaveAs(Server.MapPath("../img")+@"\qichi\productPic\"+"B"+DateTime.Now.GetDateTimeFormats()[40].Replace(' ','_').Replace(':','_')+fileBName);
                        }
                        catch(Exception ee)
                        {
                            Response.Write("<script language=javascript>alert('图片上传错误。'+ee.Message);");
                            Response.Write("</script>");
                        }                    #endregion                               
      

  3.   

    [align=left]byte[] Image_img = (byte[])ds_image.Tables[0].Rows[0]["Image_im"];
                                if (Image_img.Length == 0)
                                    return;
                                int filelength = Image_img.Length;
                                string imageName = ds_image.Tables[0].Rows[0][1].ToString() + "1" + ".jpg";
                                string myUrl = HttpContext.Current.Server.MapPath(this.Request.ApplicationPath) + @"\TempDownLoad\" + imageName;
                                FileStream fs = new FileStream(myUrl, FileMode.OpenOrCreate);
                                BinaryWriter w = new BinaryWriter(fs);
                                w.BaseStream.Write(Image_img, 0, filelength);
                                w.Flush();
                                w.Close();[/align]
    --
    主要是你的文件路径和名称不想愁,试下上面的方式吧
      

  4.   

    楼主是路径问题
    protected void doUpload()
        {
            try
            {
                HttpPostedFile file = file1.PostedFile;//获取路径
                string lastname = GetExtension(file.FileName);//获取扩展名,并且正则判断是否合格/合格则返回扩展名/不合格则返回String.Empty
                if (lastname != string.Empty)
                {
                    string strNewPath = GetSaveFilePath() + lastname;//日期文件夹+时间重命名文件
                    file.SaveAs(picPath + strNewPath);//保存文件到服务器,picPath = Server.MapPath("upload\\");
                    string urlPath = picServer + strNewPath;//相对路径--准备保存数据库存放地址
                    WriteJs("parent.uploadsuccess('" + urlPath + "','" + itemID + "'); ");//这步是我用来返回地址到JS做出的ajax效果,LZ可放弃
                    insert(urlPath);//相对URL存放数据库
                }
            }
            catch (Exception ex)
            {
                WriteJs("parent.uploaderror();");//这步是我用来返回JS异常显示的ajax 效果
            }
        }private string GetSaveFilePath()
        {
            try
            {
                string dir = DateTime.Now.ToString(@"\\yyyyMMdd");//年月日--创建时间文件夹,防止文件过多检索过慢
                if (!Directory.Exists(picPath + dir))//检索upload文件夹下年月日文件夹是否存在
                {
                    Directory.CreateDirectory(picPath + dir);//不存在则创建改文件夹
                }
                return dir + DateTime.Now.ToString("\\\\yyyyMMddhhmmssffff");//返回日期文件夹+时间重命名文件,如:20080508/2008050812501245
            }
            catch (Exception ex)
            {
                WriteJs("parent.uploaderror();");//这步是我用来返回JS异常显示的ajax 效果
                return string.Empty;
            }
        }
      

  5.   

    我看应该是路径有点问题,try
                        {
                            //保存路径
                            System.IO.Directory.CreateDirectory(Server.MapPath("../img")+@"\\qichi\\productPic\\");
                            fileBPic.PostedFile.SaveAs(Server.MapPath("../img")+@"\\qichi\\productPic\\"+"B"+DateTime.Now.GetDateTimeFormats()[40].Replace(' ','_').Replace(':','_')+fileBName);
                        }
                        catch(Exception ee)
                        {
                            Response.Write("<script language=javascript>alert('图片上传错误。'+ee.Message);");
                            Response.Write("</script>");
                        }
    你把路径改个试试看,还有就是目录需要有写入权限
      

  6.   

    System.IO.Directory.CreateDirectory(Server.MapPath("../img")+@"/qichi/productPic/");
                            fileBPic.PostedFile.SaveAs(Server.MapPath("../img")+@"/qichi/productPic/"
      

  7.   

    string path=Server.MapPath("../img/qichi/productPic/"); 
    System.IO.Directory.CreateDirectory(path);                         fileBPic.PostedFile.SaveAs(path);
      

  8.   

    本地没问题,很明显是服务器目录的权限设置问题,增加img目录中的user可写权限试下.