如果已经实现了精细的上传器并且可以上传文件。我还将允许的扩展名设置为仅允许 PDF。
但是,例如,当我尝试上传和 jpg 时,什么也没有发生。
通常这不是问题,但我想看到一条消息。这适用于fineuploader网站,但不适用于我。
希望可以有人帮帮我。
代码:
createUpload({ button: $('#dienstverleningsDocumentUploader'),
endpoint:'/adviseur/profile/dienstverleningsDocument/' + '@Model.Adviseur.ServiceDocumentID',
messages: $('#dienstverleningsDocumentMessage'), allowedExtensions: ['pdf'] });
function createUpload(options) {
var button = options.button[0];//Should be a jQuery $(...)
var endpoint = options.endpoint;
var allowedExtensions = options.allowedExtensions || ['doc', 'xls', 'docx', 'xlsx', 'pdf'];
var sizeLimit = options.sizeLimit || 10000000;// 10Mb
var itemLimit = options.itemLimit || 10;
var messages = options.messages || $('#messages');
var complete = options.complete;
return new qq.FineUploaderBasic({
button: button,
request: {
endpoint: endpoint
},
validation: {
allowedExtensions: allowedExtensions,
sizeLimit: sizeLimit,
itemLimit: itemLimit
},
callbacks: {
onSubmit: function (id, fileName) {
messages.html('<div id="file-' + id + '" class="alert" style="margin: 20px 0 0"></div>');
},
onUpload: function (id, fileName) {
$('#file-' + id).addClass('alert-info')
.html('<img src="client/loading.gif" alt="Initializing. Please hold."> ' +
'Initializing ' +
'“' + fileName + '”');
},
onProgress: function (id, fileName, loaded, total) {
if (loaded < total) {
progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';
$('#file-' + id).removeClass('alert-info')
.html('<img src="client/loading.gif" alt="In progress. Please hold."> ' +
'Uploading ' +
'“' + fileName + '” ' +
progress);
} else {
$('#file-' + id).addClass('alert-info')
.html('<img src="client/loading.gif" alt="Saving. Please hold."> ' +
'Saving ' +
'“' + fileName + '”');
}
},
onComplete: function (id, fileName, responseJSON) {
if (responseJSON.success) {
$('#file-' + id).removeClass('alert-info')
.addClass('alert-success')
.html('<i class="icon-ok"></i> ' +
'“' + fileName + '”' +
'succesvol.'
);
if (complete) {
complete(fileName, responseJSON);
}
} else {
$('#file-' + id).removeClass('alert-info')
.addClass('alert-error')
.html('<i class="icon-exclamation-sign"></i> ' +
'Uploaden mislukt bij: ' +
'“' + fileName + '”: ' +
responseJSON.error);
}
}
}
});
}