我正在使用 Dropzone.js 上传项目图片。我需要通过重新排列顺序来上传图像。我已经使用.sortable()方法重新排列图像顺序。但是当我单击上传按钮时,图像会根据图像大小上传(首先是低 MB 文件)。我怎样才能根据我安排的顺序发送图像。这是我的代码。
var dropzone = new Dropzone('#vehiImgUpload', {
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
previewTemplate: document.querySelector('#preview-template').innerHTML,
dictDefaultMessage:'Drop files here or Click to Upload',
uploadMultiple: true,
parallelUploads: 50,
thumbnailHeight: 120,
thumbnailWidth: 120,
maxFilesize: 8,
timeout: 180000,
filesizeBase: 1024,
addRemoveLinks: true,
maxFiles: 50,
autoProcessQueue: false,
removedfile: function(file) {
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
},
thumbnail: function(file, dataUrl) {
if (file.previewElement) {
file.previewElement.classList.remove("dz-file-preview");
var images = file.previewElement.querySelectorAll("[data-dz-thumbnail]");
for (var i = 0; i < images.length; i++) {
var thumbnailElement = images[i];
thumbnailElement.alt = file.name;
thumbnailElement.src = dataUrl;
}
setTimeout(function() { file.previewElement.classList.add("dz-image-preview"); }, 1);
}
},
init: function () {
$('#vehicleAddBtn').on('click',function(e) {
e.preventDefault();
if (dropzone.getQueuedFiles().length > 0) {
dropzone.processQueue();
}
else {
// Upload anyway without files
var blob = new Blob();
blob.upload = { 'chunked': dropzone.defaultOptions.chunking };
dropzone.uploadFile(blob);
}
});
this.on('success', function(file, response) {
alert('success')
this.removeAllFiles();
});
}
});