
<form onsubmit="return fileCountCheck(this);">
<input type="file" name="mulUp[]" multiple="multiple" required="required" />
<input type="submit" />
</form>
<script type="text/javascript">
function fileCountCheck(objForm){
if (windowFile && windowFileList) {
var fileCount = objForm["mulUp[]"]fileslength;
if(fileCount > 10){
windowalert('文件数不能超过10个,你选择了' + fileCount + '个');
}
else {
windowalert('符合规定');
}
}
else {
windowalert('抱歉,你的浏览器不支持FileAPI,请升级浏览器!');
}
return false;
}
</script>
扩展资料:
java获取路径,文件名的方法总结
1、文件路径获取
ThreadcurrentThread()getContextClassLoader()getResource(“”) //获得资源文件(class文件)所在路径
ClassLoadergetSystemResource(“”)
ClassNameclassgetClassLoader()getResource(“”)
ClassNameclass getResource(“/”)
ClassNameclass getResource(“”) // 获得当前类所在路径
SystemgetProperty(“userdir”) // 获得项目根目录的绝对路径
SystemgetProperty(“javaclasspath”) //得到类路径和包路径
其中ClassName为类名。
2、文件名获取
String fName =” D:\java\workspace\netmanager01\resources\mibfiles\wtViewmib “;
(“\”,java中需要转义)
第一种:
File tempFile =new File( fName trim());
String fileName = tempFilegetName();
第二种:
fName = fNametrim();
fileName = fNamesubstring(fNamelastIndexOf("/")+1);
或者
fileName = fNamesubstring(fNamelastIndexOf("\\")+1);
第三种:
fName = fNametrim();
String temp[] = fNamesplit("\\\\"); //split里面必须是正则表达式,"\\"的作用是对字符串转义,其中split("\\\\")的作用是:按照"\\"为分隔符,将路径截取,并存入数组,如下:temp[]=[,D:,java,workspace,netmanager01,resources,mibfiles,wtViewmib]
fileName = temp[templength-1];(取出最后一个)
以上就是关于js获取HTML5 多文件file选择的数量全部的内容,包括:js获取HTML5 多文件file选择的数量、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)