我在 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');