gpt4 book ai didi

jquery - fineUploader 最小文件数验证

转载 作者:行者123 更新时间:2023-12-01 07:18:10 27 4
gpt4 key购买 nike

我在 MVC 4 中使用 FineUploader,我意识到如果没有选择文件,fineUploader 就不会发布,我想知道是否有验证让用户上传至少一个文件?下面是我如何使用fineUploader。

// INITIALIZING FINEUPLOADER

manualUploader = $('#' + uploaderElementId).fineUploader({
request: {
endpoint: endPoint
},
multiple: false,
autoUpload: false,
validation: {
allowedExtensions: allowedExtensions,
sizeLimit: 20971520 // 50 kB = 50 * 1024 bytes
},
text: {
uploadButton: 'Select file'
}
}).on('submit', function (id, fileName) {
//do nothing
}).on('complete', function (event, id, fileName, responseJSON) {
if (responseJSON.success && responseJSON.fileId !== undefined) {
if (isImage) {
$(this).prepend('<img src="/Webservices/FileStream.ashx?mode=download&fileid=' + responseJSON.fileId + '" class="webinar-image" />');
}
else {
$(this).prepend('<a href="/Webservices/FileStream.ashx?mode=download&fileid=' + responseJSON.fileId + '">Uploaded File</a>');
}
}
}).on('error', function (xhr, id, name, errorReason) {
self._onfailUpload(errorReason);
}); //end INIT FINE UPLOADER

//POSTING FINEUPLOADER
manualUploader.fineUploader('setParams', {
'__RequestVerificationToken': $("input[name='__RequestVerificationToken']").val(),
"webinarId": data.webinarId,
"fileType" : "Pdf"
});
manualUploader.fineUploader('uploadStoredFiles');

最佳答案

是的,有办法!

假设您有某种 onClick 事件处理程序...

function handleUploadStoredFilesClick() {
// qq.status.SUBMITTED is the status reserved for files added
// to the uploader but not yet uploaded
var storedFiles = $('#myuploader').fineUploader('getUploads', { status: qq.status.SUBMITTED }).length

// Here we check if the number of storedFiles is greater than 0,
if (storedFiles > 0) {
$('#myuploader').fineUploader('uploadStoredFiles');
}
else {
//alert user that there are no files to upload
}
}

还有an open issue on Github引用这个问题。下一个版本将提供潜在的解决方案。

关于jquery - fineUploader 最小文件数验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16944677/

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