[英]blueimp jQuery file upload new files order
我正在嘗試在blueimp文件上傳腳本中找到位置以更改表中新文件位置的行為。 如何通過添加在文件列表末尾的表格頂部來強制它們?
只需添加屬性
例:
$('.fileupload').fileupload({
url: 'your_url',
dataType: 'json',
prependFiles:true
});
我通過覆蓋fileuploaddone的事件監聽器並添加prepend而不是append來做到這一點。
它看起來像這樣
$('.fileupload').fileupload({
url: 'phpUpload/index.php?customDir='+saveFolder,
dataType: 'json',
dropZone: $(this),
autoUpload: true,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png|pdf|mp3|mp4|wav|doc|docx|ppt)$/i,
maxFileSize: 150000000, // 150 MB
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent),
previewMaxWidth: 100,
previewMaxHeight: 100,
previewCrop: true
}).on('fileuploadadd', function (e, data) {
// you can leave this out if you want the default design
data.context = $('<div/>').addClass('existingMediaFile');
$.each(data.files, function (index, file) {
var node = $('<a/>').append($('<span/>').text(file.name));
node.appendTo(data.context);
});
}).on('fileuploaddone', function (e, data) {
$.each(data.result.files, function (index, file) {
$(data.context.children()[index]).prepend(file.name+' '+file.thumbnailUrl);
});
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.