gpt4 book ai didi

javascript 不能在头部工作但在 body 中工作

转载 作者:行者123 更新时间:2023-11-30 15:14:58 26 4
gpt4 key购买 nike

<分区>

您好,我是从 http://jsfiddle.net/AbdiasSoftware/TsxzR/ 得到这个教程的当这段代码在 body 标签中时效果很好但是当它在 head 标签中时这不起作用我是 javascript 的业余爱好者请帮助我

我的 html 代码:

 <input type="file" name="file" id="confirm">
<input type="file" name="file" id="approveletter">

我的 JavaScript 代码:

document.getElementById('confirm').addEventListener('change', checkFile, false);
approveletter.addEventListener('change', checkFile, false);

function checkFile(e) {

var file_list = e.target.files;

for (var i = 0, file; file = file_list[i]; i++) {
var sFileName = file.name;
var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1].toLowerCase();
var iFileSize = file.size;
var iConvert = (file.size / 10485760).toFixed(2);

if (!(sFileExtension === "pdf" || sFileExtension === "doc" || sFileExtension === "docx") || iFileSize > 10485760) {
txt = "File type : " + sFileExtension + "\n\n";
txt += "Size: " + iConvert + " MB \n\n";
txt += "Please make sure your file is in pdf or doc format and less than 10 MB.\n\n";
alert(txt);
}
}
}

谢谢

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