The given path's format is not supported.

问题

编程以来今本没有使用input[type=file]这个控件过,今天突然使用尽然报错了,在本地chrome,firefox等其他的浏览器都是好的,唯独ie报错了。在服务器的时候,尽然chrome也是报错的。

问题原因

出现这个错误的主要原因是,在本地上传图片的时候HttpPostedFileBase对象里面保存的FileName仅仅是文件的名称而已

而部署服务器上的时候上传FileName却是你本地上传的物理路径,也就是本地完整的路劲,如下图

解决问题

所以导致我们在执行如下代码的时候会报错

                fileName = imgLogo.FileName;

                string type = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();
                if (!ValidateImg(type))
                {
                    ErrorModel errorModel = new ErrorModel("imgLogo", "只能上传图片文件!");
                    ViewBag.errorModel = errorModel;
                    return View(config);
                }
                //全路劲,导致这里的server.mappath得到的服务器路劲其实错误了,所以下面的saveas会直接报错
                var path = Server.MapPath("~/images/" + fileName);
                
                imgLogo.SaveAs(path);

既然知道原因了,那么解决起来也就很简单了,处理一下fileName就好了,代码如下

         //只需要在这里截取出文件名称就好了
                fileName = imgLogo.FileName.Substring(imgLogo.FileName.LastIndexOf("\\") + 1); ;

                string type = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();
                if (!ValidateImg(type))
                {
                    ErrorModel errorModel = new ErrorModel("imgLogo", "只能上传图片文件!");
                    ViewBag.errorModel = errorModel;
                    return View(config);
                }
                //全路劲,导致这里的server.mappath得到的服务器路劲其实错误了,所以下面的saveas会直接
                var path = Server.MapPath("~/images/" + fileName);
                
                imgLogo.SaveAs(path);

 

转载于:https://www.cnblogs.com/ylchen/p/3826216.html

–mkdir: Unknown command Usage: hadoop fs [generic options] [-appendToFile <localsrc> ... <dst>] [-cat [-ignoreCrc] <src> ...] [-checksum <src> ...] [-chgrp [-R] GROUP PATH...] [-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...] [-chown [-R] [OWNER][:[GROUP]] PATH...] [-copyFromLocal [-f] [-p] [-l] [-d] <localsrc> ... <dst>] [-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] [-count [-q] [-h] [-v] [-t [<storage type>]] [-u] [-x] <path> ...] [-cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>] [-createSnapshot <snapshotDir> [<snapshotName>]] [-deleteSnapshot <snapshotDir> <snapshotName>] [-df [-h] [<path> ...]] [-du [-s] [-h] [-x] <path> ...] [-expunge] [-find <path> ... <expression> ...] [-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] [-getfacl [-R] <path>] [-getfattr [-R] {-n name | -d} [-e en] <path>] [-getmerge [-nl] [-skip-empty-file] <src> <localdst>] [-help [cmd ...]] [-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]] [-mkdir [-p] <path> ...] [-moveFromLocal <localsrc> ... <dst>] [-moveToLocal <src> <localdst>] [-mv <src> ... <dst>] [-put [-f] [-p] [-l] [-d] <localsrc> ... <dst>] [-renameSnapshot <snapshotDir> <oldName> <newName>] [-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ...] [-rmdir [--ignore-fail-on-non-empty] <dir> ...] [-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]] [-setfattr {-n name [-v value] | -x name} <path>] [-setrep [-R] [-w] <rep> <path> ...] [-stat [format] <path> ...] [-tail [-f] <file>] [-test -[defsz] <path>] [-text [-ignoreCrc] <src> ...] [-touchz <path> ...] [-truncate [-w] <length> <path> ...] [-usage [cmd ...]] Generic options supported are: -conf <configuration file> specify an application configuration file -D <property=value> define a value for a given property -fs <file:///|hdfs://namenode:port> specify default filesystem URL to use, overrides 'fs.defaultFS' property from configurations. -jt <local|resourcemanager:port> specify a ResourceManager -files <file1,...> specify a comma-separated list of files to be copied to the map reduce cluster -libjars <jar1,...> specify a comma-separated list of jar files to be included in the classpath -archives <archive1,...> specify a comma-separated list of archives to be unarchived on the compute machines The general command line syntax is: command [genericOptions] [commandOptions]
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值