我有个网站用fileUpLoad上传图片,在装了vs的电脑上上传没问题,但在正常使用人员的电脑上他们操作后台时上传图片报
The given path's format is not supported 这个错误,我从没见过这种情况,请问大家这是怎么回事呀,要怎么处理。

解决方案 »

  1.   

    贴出路径
    @"";
    http://social.msdn.microsoft.com/Forums/en/Vsexpressvcs/thread/467bf8e6-1b18-47cb-bde1-458430b1d2de
      

  2.   

    你上传的话,要用Server.MapPath()取Server的路径
      

  3.   

    我弹出路径看了变成了:cadminimagea.jpg
    原本路径:c://admin//image/a.jpg
    所以程序报路径格式不正确
      

  4.   

      /// <summary>
        /// 上传图片方法
        /// </summary>
        /// <param name="ful">上传控件</param>
        /// <param name="path">上传路径</param>
        public static bool UpLoadFile(FileUpload ful, string path, out string filename)
        {
            bool value = false;
            filename = "";
            try
            {            if (!string.IsNullOrEmpty(ful.PostedFile.FileName.Trim()))
                {
                    if (ful.PostedFile.ContentLength > 10240000)
                    {
                        value = false;
                    }
                    else
                    {
                        filename = DateTime.Now.ToString("yyMMddhhss") + ful.PostedFile.FileName;
                        string paths =path + filename;
                        ful.PostedFile.SaveAs(paths);
                        value = true;
                    }
                }
                return value;
            }
            catch (FileLoadException ex)
            {
                throw ex;
            }
      

  5.   

    这个是我放在add_code里的一个上传图片的方法
      

  6.   

    既然路径里面有连个//,你就进行替换下啊
    path = path.Replace("\\\\","\\");
      

  7.   

    但客户哪边上传就报  The given path's format is not supported
      

  8.   

    Server.Mappath我在事件里string path是追加了的
    这个方法里传的就是Server.mappath路径+图片名
      

  9.   

    //添加产品记录
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                try
                {
                    string filename = null, maxname = null;
                    string tempPath = @"" + Server.MapPath(path);
                    if (HelperCode.UpLoadFile(this.fulUpLoad, tempPath, out filename) == false ||
                        HelperCode.UpLoadFile(this.fulMax, tempPath, out maxname) == false)
                    {
                        this.spMes.InnerHtml = "请检查是否有上传图片并且允许上传最大值为100MB!";
                    }
                    else if (bll.AddProductById(GetObj(0, filename, maxname)) > 0)
                    {
                        this.spMes.InnerHtml = "增加[" + this.txtName.Text + "]产品成功!页面将在三秒后自动更新.";
                        script();
                    }
                    else
                    {
                        this.spMes.InnerHtml = "sorry!增加[" + this.txtName.Text + "]产品过程中出现异常!请检查输入数据。.";
                    }
                }
                catch (Exception ex)
                {
                    this.spMes.InnerHtml = "sorry!" + ex + "可能产品编号有重复!";
                }
            }
        }
      

  10.   

    怎么会无从查起呢?
    哪行报错在哪行前面加调试信息。变量赋值没有必要加 @"" 
     string tempPath = Server.MapPath(path); 
    就 可以了
      

  11.   

    问题是我本机测试是正常的,有VS工具的电脑测试都是正常的,而放到网上没有装VS的都报错,我在服务器上无法调试呀。
      

  12.   

    sorry!System.NotSupportedException: The given path's format is not supported. at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, AccessControlActions control, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath) at 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) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at HelperCode.UpLoadFile(FileUpload ful, String path, String& filename) at admin_products_Default.btnAdd_Click(Object sender, EventArgs e)可能产品编号有重复!
      

  13.   

    catch (Exception ex)
                {
                    this.spMes.InnerHtml = "sorry!" + ex + "可能产品编号有重复!";
                }
      

  14.   

    你把调试信息在页面上打出来啊。比如
    http://xxx,.aspx?debug=1就显示出调试信息,方便自己查看,其他人不知道这个参数windows路径是这样的
    c:\admin\image\a.jpgLunix路径是这样的
    c:/admin/image/a.jpg莫非那个机器不是windows操作系统?
      

  15.   

    path = path.Replace("//","/");
      

  16.   

    我也遇到了这个问题啊.....在服务器上执行程序导入,结果就报这个错误.... 我本地测试是正确的。
    本地就上这样的: string fileName = @"D:\UpFiles\" +file_upload.PostedFile.FileName;