gpt4 book ai didi

javascript - 如何验证 uploadFile js 中的格式

转载 作者:行者123 更新时间:2023-11-28 05:45:56 26 4
gpt4 key购买 nike

我有一个问题,我正在通过 uploadfile js 创建一个上传函数。如果文件不是excel文件,系统将显示错误。如何通过uploadfile js实现验证excel格式?这是我的来源

$(document).ready(function() {
var uploadObj = $("#fileuploader").uploadFile({
url:"php/upload.php",
fileName:"myfile",
uploadStr: "Nhập file upload",
abortStr:"Hủy bỏ",
uploadErrorStr:"Lỗi khi upload, vui lòng kiểm tra lại",
sizeErrorStr:"Dung lượng file vượt quá giới hạn",
autoSubmit:false
});
});

最佳答案

您尝试过 allowedTypes: 'xls,xslx' 吗?

您也可以尝试 onSelect 回调:

onSelect: function(files) {

if (files[0].type != 'application/vnd.ms-excel') {
throw new Error('Not excel file');
}
}

关于javascript - 如何验证 uploadFile js 中的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38523551/

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