i'm trying to find place inside blueimp file upload scripts to change the behavior of new files position in the table. How to force them to by added at the top of the table insted of the end of files list?
Just add the property prependFiles:true
Example:
$('.fileupload').fileupload({
url: 'your_url',
dataType: 'json',
prependFiles:true
});
I did it by overwriting the event listener for fileuploaddone and adding prepend instead of append.
It look like this
$('.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);
});
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With