简体   繁体   English

JS清算 <input type = “file”> 选

[英]JS for clearing <input type = “file”> selections

Once the user chooses the file, I have a condition using html5 file api to check if the file size exceeds a 1mb. 一旦用户选择了文件,我就有条件使用html5文件api检查文件大小是否超过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? 当处理程序知道文件超过一定大小时,我想在我的输入标签上运行以清除/强制客户端选择另一个文件的脚本是什么?

 var _fileuploadcontrolId = document.getElementById("id");
            _fileuploadcontrolId.value = "";
            _fileuploadcontrolId.focus();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM