怎么在提交表单之前检查文件名字的大小

wuyuwww 2012-08-02 09:28:40
<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>


function onCheck()
{
var path = document.getElementById("file").text;
path = path.substring(path.lastIndexOf("\\")+1,path.length);
alert(path);
return false;

}

问题是我一次上传多个文件的时候,他onclick这个只能得到一个文件的名字,其他文件的名字就是得不到,我们用的框架是cakePHP,不知道为啥?球高手,我整了好处时间都没整出来
...全文
75 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyuwww 2012-08-02
  • 打赏
  • 举报
回复
先去弄弄在说啊
一起混吧 2012-08-02
  • 打赏
  • 举报
回复
用 document.getElementsByName 和for循环
zhangqinhappy 2012-08-02
  • 打赏
  • 举报
回复
能否用getElementsByName试试呢?

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧