2

In D7, I've got some forms that are responsible for uploading potentially large video files via managed_form fields. My server is properly set up for showing uploadprogress (or seems to be, according to phpinfo and Drupal's status report), but when I submit the form via the Submit button, I get no progress bar. Is this just "how it works"?

It's probably worth noting that I've hidden the "Upload" button after a long series of usability problems with my site's users, so that may be a blindingly obvious factor in my problem. But I'm still interested in getting some sort of upload indication in response to the Submit button; I'm not averse to bashing some stuff into the page via a jQuery .submit() handler or whatever if that's what it takes. Is there a way for me to have my cake and eat it too? Thanks!

5

Is this just "how it works"? - Yes, it's just how it works. This is a problem with HTTP protocol, if your site does not provide client-side implementation for that progress bar, it will not be shown. And Drupal forms are standard HTML / HTTP POST forms, so no implementation provided for traditional, old style POST.

What I do in such situations is:

With plupload

uploader.bind('QueueChanged', function() {

to automatically start upload and disable form's submitting. Then

uploader.bind('StateChanged', function() {

to reenable form's submitting once upload is done.

Without plupload

AutoUpload module has some good example code how to react on file selection and upload finish. I steal from it to do basically the same thing as above - disable form submitting when new file is added, enable it when it's uploaded. Alternatively, form submit behavior may start uploading files not yet uploaded, and only submit form when uploads finished.

Without traditional POST

If you can give up traditional submit, and re-write it with AJAX, leaving traditional way in place for graceful degradation, you can have a progress bar for a whole form. But it is a quite big task, too broad to cover in Q&A format (at least for me).

  • This looks really promising; thanks! But I'm still unsure how I would get the progress bar into the page. That presumably happens inside the QueueChanged handler, but what goes on there? – Jim Miller Apr 18 '14 at 14:29
  • @JimMiller sorry, but the actual code I'm using is not to be distributed. If you will try to implement specific way and will have problems with specific part, feel free to ask them as new questions, and comment here with links. I'll try to help. Sadly, that's about all I can really do for you (without taking your money for re-implementing it, that is). Hint: plupload provides it's own progress bar for each queue. If this satisfy you, you don't need to care, just start uploading and see it work. – Mołot Apr 19 '14 at 9:30
  • Understood; I'll look into it. – Jim Miller Apr 19 '14 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.