日期:2014-05-18  浏览次数:20508 次

***急*****网站的文件上传问题
我的网站中提供用户上传图片,我在自己的电脑上测试上传正常,
但是放到空间服务商服务器上就不行了。代码如下::

  if   (txtImg.PostedFile.FileName   !=   " ")
                {
                        System.IO.FileInfo   fs   =   new   System.IO.FileInfo(txtImg.PostedFile.FileName);
                        if   (fs.Exists)
                        {
                                string   filename   =   obj.ni_id.ToString()   +   fs.Extension.ToString();

                                string   mPath   =   Common.GetConfig( "MainPath ");
                                string   path   =   mPath   +   Common.GetConfig( "NewImgPath ")   +   filename;
                                string   pathcurr   =   Common.GetConfig( "NewImgPathCurr ");
                                txtImg.PostedFile.SaveAs(path);

                                string   strPath   =   pathcurr   +   filename;

                                cols.Add( "img_url ");
                                vals.Add(strPath);
                        }
                }


在外网连   if   (txtImg.PostedFile.FileName   !=   " ")或
  System.IO.FileInfo   fs   =   new   System.IO.FileInfo(txtImg.PostedFile.FileName);
                        if   (fs.Exists)
这2个判断都没有通过。是不是服务商的电脑不支持txtImg.PostedFile.FileName   还是不支持System.IO.FileInfo   fs   =   new   System.IO.FileInfo(txtImg.PostedFile.FileName);这个呢??

急切期盼高手帮忙!!!!


------解决方案--------------------
PostedFile里的File是客户端的机器上的文件,System.IO.FileInfo只能对服务器端的文件起作用,根本就不是一个概念!!!
------解决方案--------------------
路径的问题 把mPath 换成Server.MapPath( "路径 ")