2

I am using Blueimp fileupload for uploading images in my project. After i load up the images, I want to place a button for the each image which can be pressed to clear it from the upload queue before the upload (like the one from the plugin's demo page@ http://blueimp.github.io/jQuery-File-Upload/). I've looked everywhere I can't seem to find a solution that actually works for me.... Here's the code I've been using...

   $('#fileupload').fileupload({
    dataType: 'json',
    autoUpload: false,
    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
disableImageResize: /Android(?!.*Chrome)|Opera/
        .test(window.navigator.userAgent),
imageMaxWidth: 1000,
imageMaxHeight: 800,
    previewMaxWidth: 100,
    previewMaxHeight: 100,
    previewCrop: false
}).on('fileuploadadd', function (e, data) {
    //Add buttons for canceling individual images
$("#uploadBttn").click(function () {
                data.submit();
    });
}).on('fileuploadprocessalways', function (e, data) {
    var index = data.index, 
        file = data.files[index];
    if (file.preview) {
        $("#imgPreview").append(file.preview);
    }
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css('width',progress + '%');
}).on('fileuploadstart', function (e) {
$("#uploadBttn").unbind().prop('disabled', true).text('Uploading...');
}).on('fileuploadstop', function (e) {
$("#uploadBttn").text('Done!');
});
3
  • possible duplicate of How to remove file from the queue to stop upload before upload starts in blueimp Basic? Commented Oct 10, 2013 at 7:36
  • Yes. I did see that question, and tried it for my stuff. Although this removes the file entry from the table, it didn't actually remove it from the upload queue. So when I click on the upload button, it ends up uploading everything including the ones that I removed from the table. Commented Oct 10, 2013 at 16:10
  • add also a button for every single file and bind the submit on it. Commented Oct 10, 2013 at 18:23

1 Answer 1

2

Make sure you set the context of your file to the table row, and then do something like this:

$("#uploadBttn").click(function () {
    if (data.context.is(":visible"))
        data.submit();
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.