Jon Skarpeteig
Jon Skarpeteig

Reputation: 4128

plupload submit on queue complete

Using plupload jquery queue plugin as in this example, how can I submit the form on upload complete? I attempted to add a <input type="submit" /> button, and click this button without first clicking the Start upload. This triggers the uploader.start() correctly, and then $('form').submit() - however the $_POST data only contains: 'uploader_count' => string '0' (length=1). If I first click the Start upload button however, the proper POST vars are populated.

How can I trigger .submit() and be sure the correct file upload post parameters are present (E.G. $_POST['uploader_count']) ?

Upvotes: 1

Views: 4374

Answers (2)

Jon Skarpeteig
Jon Skarpeteig

Reputation: 4128

Turns out this is a bug in plupload, and is also present in the official example at:

http://www.plupload.com/example_queuewidget.php

(Queing files, then hit submit only sends POST data $_POST['uploader_count'] == 0) omitting any file info

Upvotes: 1

chx
chx

Reputation: 11760

We added a button which does this:

    var plupload = form.find('.plupload-element'), uploader;
    event.preventDefault();
    if (plupload.length && plupload.pluploadQueue) {
      uploader = plupload.pluploadQueue();
      uploader.bind('StateChanged', function(uploader) {
        // Submit the form if all the files got uploaded.
        if (uploader.total && uploader.files && uploader.total.uploaded === uploader.files.length) {
          form.trigger('submit');
        }

Upvotes: 0

Related Questions