怎么在提交表单之前检查文件名字的大小
- HTML code
<form action="/testresults/upload" method="post" enctype="multipart/form-data"> <input type="file" id ='file' class="multi" accept="xml|csv|jpg" name="files[]"/> <input style="width:90px;height:40px;" type="button" value="Upload" onclick='return onCheck()'/></form>
- JScript code
function onCheck(){ var path = document.getElementById("file").text; path = path.substring(path.lastIndexOf("\\")+1,path.length); alert(path); return false;}
问题是我一次上传多个文件的时候,他onclick这个只能得到一个文件的名字,其他文件的名字就是得不到,我们用的框架是cakePHP,不知道为啥?球高手,我整了好处时间都没整出来
[解决办法]
能否用getElementsByName试试呢?
[解决办法]
用 document.getElementsByName 和for循环