Session Upload Progress

When the
session.upload_progress.enabled
INI option is enabled, PHP will be able to track the upload progress of
individual files being uploaded.
This information isn't particularly useful for the actual upload request
itself, but during the file upload an application can send a POST request
to a separate endpoint (via XHR for example) to check the
status.

It is also possible to cancel the currently in-progress file
upload, by setting the $_SESSION[$key]["cancel_upload"] key to
TRUE.
When uploading multiple files in the same request, this will only cancel the
currently in-progress file upload, and pending file uploads, but will not
remove successfully completed uploads.
When an upload is cancelled like this, the error key in
$_FILES array will be set to
UPLOAD_ERR_EXTENSION.

User Contributed Notes 15 notes

Note, this feature doesn't work, when your webserver is runnig PHP via FastCGI. There will be no progress informations in the session array.Unfortunately PHP gets the data only after the upload is completed and can't show any progress.

If you're seeing"PHP Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0",then a misplaced input could be the cause. It's worth mentioning again that the hidden element MUST be before the file elements.

in your form, but you DON'T specify an input with 'type="file"', you may lose your session ID. I am using PHP 5.5 and I lose my session ID on the second loading of such a page. To prevent this, you can use a dummy input as follows:

Note that if you run that code and you print out the content of $_SESSSION[$key] you get an empty array due that session.upload_progress.cleanup is on by default and it cleans the progress information as soon as all POST data has been read.

It also be noted that dhinka chika, dhinka chika, ae ae. Other wise none of the $_SESSION super global variable will get any of the information related to uploading. Always define global $hoogalala before initializing any upload form.