select As soon as the user selects the file, I have a condition using the html5 api file to check if the file...">

JS to clear the <input type = "file"> select

As soon as the user selects the file, I have a condition using the html5 api file to check if the file size is larger than 1 Mb.

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 that I would like to run in my input tag to clear / force the client to select another file when the handler knows that the file is larger than a certain size?

+4
source share
1 answer
  var _fileuploadcontrolId = document.getElementById("id"); _fileuploadcontrolId.value = ""; _fileuploadcontrolId.focus(); 
+10
source

Source: https://habr.com/ru/post/1483516/


All Articles