最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JS for clearing <input type = "file"> selections - Stack Overflow

programmeradmin0浏览0评论

Once the user chooses the file, I have a condition using html5 file api to check if the file size exceeds a 1mb.

function handleLimit(evt) {
   var files = evt.target.files; 
   f = files[0];
   console.log(f.size);
   if (f.size > 1048576) {
          /*JS for clearing form*/
   }
}

What would be the script I would want to run on my input tag to clear/ force the client to choose another file it once the handler knows that file is exceeding a certain size?

Once the user chooses the file, I have a condition using html5 file api to check if the file size exceeds a 1mb.

function handleLimit(evt) {
   var files = evt.target.files; 
   f = files[0];
   console.log(f.size);
   if (f.size > 1048576) {
          /*JS for clearing form*/
   }
}

What would be the script I would want to run on my input tag to clear/ force the client to choose another file it once the handler knows that file is exceeding a certain size?

Share Improve this question asked May 30, 2013 at 5:07 EmaneguxEmanegux 1,1202 gold badges20 silver badges39 bronze badges 1
  • 2 stackoverflow./questions/1043957/… should get you there. – Bill Criswell Commented May 30, 2013 at 5:12
Add a ment  | 

1 Answer 1

Reset to default 10
 var _fileuploadcontrolId = document.getElementById("id");
            _fileuploadcontrolId.value = "";
            _fileuploadcontrolId.focus();
发布评论

评论列表(0)

  1. 暂无评论