选择的 JS-6ren"> 选择的 JS-一旦用户选择了文件,我就有条件使用 html5 文件 api 检查文件大小是否超过 1mb。 function handleLimit(evt) { var files = evt.target-6ren">
gpt4 book ai didi

javascript - 用于清除 <input type = "file"> 选择的 JS

转载 作者:搜寻专家 更新时间:2023-11-01 05:01:24 24 4
gpt4 key购买 nike

一旦用户选择了文件,我就有条件使用 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*/
}
}

一旦处理程序知道文件超过特定大小时,我想在我的输入标签上运行什么脚本来清除/强制客户端选择另一个文件?

最佳答案

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

关于javascript - 用于清除 &lt;input type = "file"> 选择的 JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16828339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com