Search code examples
javascriptjqueryblueimp

Blueimp jQuery-File-Upload : User feedback before upload


Using blueimp (https://github.com/blueimp/jQuery-File-Upload) I would like to be able to pause/stop the upload after the user starts it and then resume it.

What I want to achieve, is to show modals that ask questions to the user regarding the items he wants to upload. Using JS confirm() does work since it blocks the execution, but I want an alternative that uses an asynchronous approach.

I have seen the many events that the library offers, including fileuploadstart, but I don't see how I can abort or pause the upload from in there and restart it later on.

I have also thought of handling it when the upload button is clicked, but I use JS templates and I am not sure where the click event bindings happen for the uploader. Also, I would have to re-bind my events every time a file gets added (since each file has its own upload button).

Is this possible in a nicely-done way?


EDIT:

If I am to make it work by handling the button clicks, I will also need a way to access the file queue form outside the plug-in. I don't see how I can achieve this either... :(


UPDATE:

I have managed to get some API for the uploader, but I still don't see a way to access the file queue:

 $('#fileupload').data('blueimpFileupload').options

Uploader API


Solution

  • OK. What I did was to ask the user when he added the files and I have inserted a property on each file object that reflected the user's choice.

    This is the event for file addition: fileuploadadded. And this (event) is where I have inserted the extra form field (that holds the user-chosen value): fileuploadsubmit.

    As far as I saw, it is not possible to get a hold of the queue of that thing, so I have been updating my own queue using the event above.