Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It is quite easy to implement upload progress feedback. It will work if the PHP installation either has APC enabled (which is very common these days), or has the small PECL extension named uploadprogress. If none of those two are available, we simply use our current upload indicator.
To test this on APC, please make sure to set apc.rfc1867 = 1
in your PHP configuration.
Comment | File | Size | Author |
---|---|---|---|
upload-progress.patch | 3.18 KB | Damien Tournoud | |
Comments
Comment #1
quicksketchWow. Fascinating! This is fantastic, I looked into this exact problem when converting upload.module to to #ahah, but I didn't know there was any way to do this in PHP. Is there anyway we could automatically set the APC variable through .htaccess? It doesn't seem to be an entirely common option.
Comment #2
quicksketchTo quote Steven:
And so we can. :)
Comment #3
rickvug CreditAttribution: rickvug commentedThis would be a excellent usability enhancement and a killer end-user feature. Tags added.
Comment #4
yoroy CreditAttribution: yoroy commentedWhere will we see this in core? in update.php and when uploading attachments?
@rickvug: really killer? I wouldn't dare to brag about this. ("Drupal 7, now with progress bars for your upload!!!")
Let's keep the bar high for items on the list of killer features :-)
Still, would be a nice touch indeed. Can we get a screenshot please?
Comment #5
Damien Tournoud CreditAttribution: Damien Tournoud commentedI'll update the patch later this day.
Edit: removing the screenshot.
Comment #6
drewish CreditAttribution: drewish commentedsubscribing... this is really cool but i wonder if there's a bug that might make this less useful. as per http://docs.php.net/manual/en/apc.configuration.php#ini.apc.rfc1867
Comment #8
quicksketchI've been trying to backport this to FileField and I've found one obvious flaw: the current approach limits us to one progress-enabled upload field per page. Since "APC_UPLOAD_PROGRESS" is a required item in the POST array, printing it in the HTML makes it so that there can only be one progress ID per form. Drewish points out APC upload progress isn't thread-safe, so maybe this is a moot point, but I feel it would be better to not hard-code the APC_UPLOAD_PROGRESS element into the page, and instead dynamically add it to the page just before submitting the form (then remove it afterwards) so in the case there are multiple progress-enabled fields, the value appears in the POST array based on the button that was pressed.
Comment #9
quicksketchI now have a working version of this for Drupal 6 in FileField, see #318960: Upload Progress Bar (rfc1867 support).
Some more observations:
Comment #12
bennos CreditAttribution: bennos commentedI have mentioned the same thing here:
http://drupal.org/node/318960
pecl upload progress is only supported by the apache. The lighttpd 1.4 has no support. the comming release of lighttpd 1.5 wil have support.
I do not know the support of other webserver, but I think the pecl extension upload progress is not the best way at this point.
Other webserver are locked out. Developers must touch the core to implement support of special webserver upload modules.
Why not implement a full ajax upload solution?
like this http://plugins.jquery.com/node/6728 or any other jquery solutions to get a better uploading.
Comment #13
quicksketchThis solution is an AJAX solution. The library you linked to just lets you upload via AJAX (which Drupal already does), it doesn't provide upload progress. Upload progress needs server-side support, since normally PHP doesn't even start executing the response script until after the entire file is already uploaded. However, it's definitely clear that this will need some more work, it's good that FileField has added this support so we can find all the various bugs. So far we already have:
#437254: Upload progress does not work in Lighttpd & nginx
#435828: Progress bar shows progress only for last file when set to unlimited (with exceptions)
#435678: Progress bar not HTTPS compatible
Comment #14
davidcgutman CreditAttribution: davidcgutman commentedWould you guys mind including some more detailed instructions on how to enable this feature? I'm a bit of a PHP novice, so what is obvious to you guys probably isn't obvious to me (or many other Drupal users). Since this notification shows up in the Status Report, adding a little more documentation would be very welcome. Looks like a great result though...
Comment #15
quicksketchdavidcgutman, this issue is for Drupal core. You're talking about the progress bar in FileField. See #441046: Upload Progress Bar Documentation.
Comment #16
Aren Cambre CreditAttribution: Aren Cambre commentedMarked #22234: progress indicator as duplicate of this one.
Comment #18
rickvug CreditAttribution: rickvug commented@quicksketch Looking at core's file.module, it looks to me like this patch was included so I'm marking as fixed. Please re-open if there are still issues to be addressed. Excited to have this in core!
Comment #20
gpk CreditAttribution: gpk commentedYes looks like this was part of the original implementation of file.module. And is now documented on the API site: http://api.drupal.org/api/function/file_progress_implementation/7.
Note that AFAIK both uploadprogress and APC work only in mod_php environments, i.e. not under CGI/FastCGI.