rfc:session_upload_progress

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:session_upload_progress [2008/09/08 10:03] – created lbarnaudrfc:session_upload_progress [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2008-09-08   * Date: 2008-09-08
   * Author: Arnaud Le Blanc <arnaud.lb@gmail.com>   * Author: Arnaud Le Blanc <arnaud.lb@gmail.com>
-  * Status: Under Discussion+  * Status: Implemented (trunk)
   * First Published at: http://wiki.php.net/rfc/session_upload_progress   * First Published at: http://wiki.php.net/rfc/session_upload_progress
   * Patch: http://arnaud.lb.s3.amazonaws.com/session_upload_progress.patch   * Patch: http://arnaud.lb.s3.amazonaws.com/session_upload_progress.patch
Line 10: Line 10:
 ===== Introduction ===== ===== Introduction =====
  
-The file upload feature in PHP allows extensions to be called back on some events. A few extensions use this to implement some sort of upload progress feedback, but none of them are released with PHP, which makes this feature unsuable in many environments.+The file upload feature in PHP allows extensions to be called back on some events. A few extensions use this to implement some sort of upload progress feedback, but none of them are released with PHP, which makes this feature unusable in many environments.
  
 ==== Upload progress in sessions ==== ==== Upload progress in sessions ====
  
-The patch allows to store upload progress informations in session variables. These informations can be retrieved by an other script while the upload is still in progress, allowing to provide feedback to the user.+The patch allows the session extension to hook into the file upload feature in order to provide upload progress information through session variables. These informations can be retrieved by script while the upload is still in progress, allowing to provide feedback to the user.
  
-Implementing this in the sessions extension makes this feature available to every one.+Implementing this in the sessions extension makes this feature available to every one and makes the different storage backends available for this purpose.
  
-Using the session extension for this purpose also allows to use the different storage backends available.+The feature comes with some ini settings, working just like APC's ones:
  
-The patch comes with 4 ini settingsworking just like APC's ones:+  * session.upload_progress.enabled[=1] : Enables/disables the feature 
 +  * session.upload_progress.cleanup[=1] : Cleanup progress data from session as soon as all post data has been read (recommended) 
 +  * session.upload_progress.prefix[=upload_progress_] : Progress data will be stored in _SESSION[session.upload_progress.prefix . _POST[session.upload_progress.name]] 
 +  * session.upload_progress.name[=PHP_SESSION_UPLOAD_PROGRESS] : If no _POST[session.upload_progress.name] is setthe feature will not be enabled 
 +  * session.upload_progress.freq[=1%] : Update session data every session.upload_progress.freq bytes uploaded. If the value is postfixed with '%', it will be interpreted as a percentage of the total post content length. 
 +  * session.upload_progress.min_freq[=1.0] Minimum delay between updates, in seconds
  
-  * session.upload_progress.enabled[=1+When session.upload_progress.enabled is set to and $_POST[session.upload_progress.nameis set and non-empty, upload informations are stored in $_SESSION[session.upload_progress.prefix . $_POST[session.upload_progress.name]]. Otherwise nothing will be done.
-  * session.upload_progress.prefix[=upload_progress_] +
-  * session.upload_progress.name[=PHP_SESSION_UPLOAD_PROGRESS] +
-  * session.upload_progress.freq[=1%]+
  
-When session.upload_progress.enabled is set to 1, and $_POST[session.upload_progress.name] is set and non-empty, upload informations are stored in $_SESSION[session.upload_progress.prefix . $_POST[session.upload_progress.name]]. +The session.upload_progress.freq and session.upload_progress.min_freq settings control how often the session data is updated. freq can be given in bytes (e.g. 100) or in percentage (e.g. 1%) of the size of the POST content length. min_freq is given in seconds (e.g. 0.5) and is the minimum interval between two updates. With a reasonable amount for these two settings, the feature has mostly no overhead.
- +
-$_POST[session.upload_progress.name] allows to follow multiple uploading-requests on the same session at the same time. Nothing will be done if it is not set or empty, so that session.upload_progress.enabled can be left to 1 without overhead (also, the upload hook is never called on non multipart/form-data requests). +
- +
-The session.upload_progress.freq setting controls how often the session data will be updated. This can be given in bytes or in percentage of the size of the POST content length. With a reasonable amount, the patch will have mostly no overhead+
- +
-The patch also allows to follow multiple files in the same request. Each file will have its own $_FILES-like array with name, tmp_name, error, bytes processed, etc.+
  
 The data stored in the session will looks like this: The data stored in the session will looks like this:
Line 79: Line 75:
 </code> </code>
  
 +The current patch also allows to cancel an upload by setting the "cancel_upload" key to true in the progress data (e.g. $_SESSION["upload_progress_123"]["cancel_upload"] = true;).
 +
 +Doing so will cancel the currently uploading file and bypass all remaining data (POST variables, uploads, etc). An upload canceled this way will have "error" set to [[http://www.php.net/manual/en/features.file-upload.errors.php|UPLOAD_ERR_EXTENSION]].
  
rfc/session_upload_progress.1220868233.txt.gz · Last modified: 2017/09/22 13:28 (external edit)