diff --git a/features/file-upload.xml b/features/file-upload.xml index e9a448f0be..ba123926b2 100644 --- a/features/file-upload.xml +++ b/features/file-upload.xml @@ -1,5 +1,5 @@ - + Handling file uploads @@ -119,7 +119,9 @@ Send this file: - PHP3 does not support $HTTP_POST_FILES. + PHP 4.1.0 or later supports short track var variable + $_FILES. PHP3 does not support + $HTTP_POST_FILES. @@ -156,12 +158,17 @@ Send this file: - Note that the "$userfile" part of the above variables is - whatever the name of the INPUT field of TYPE=file is in the upload - form. In the above upload form example, we chose to call it - "userfile" + Note that the "$userfile" part of the above + variables is whatever the name of the INPUT field of TYPE=file is + in the upload form. In the above upload form example, we chose to + call it "userfile" - + + + register_globals = On is not recommended for + security and performance reason. + + Files will by default be stored in the server's default temporary directory, unless another location has been given with the Validating file uploads - The following examples are for versions of PHP 3 greater than - 3.0.16, and versions of PHP 4 greater than 4.0.2. See the - function entries for is_uploaded_file and + The following examples are for versions of PHP 4 greater than + 4.0.2. See the function entries for + is_uploaded_file and move_uploaded_file. -]]> - - - For earlier versions of PHP, you'll need to do something like - the following. - - - This will not work in versions of PHP 4 - after 4.0.2. It depends on internal functionality of PHP which - changed after that version. - - - - - ]]> @@ -234,9 +208,10 @@ if (is_uploaded_file($HTTP_POST_FILES['userfile'])) { The PHP script which receives the uploaded file should implement whatever logic is necessary for determining what should be done with the uploaded file. You can for example use the - $HTTP_POST_FILES['file_size'] variable to throw - away any files that are either too small or too big. You could - use the $HTTP_POST_FILES['file_type'] variable + $HTTP_POST_FILES['userfile']['size'] variable + to throw away any files that are either too small or too big. You + could use the + $HTTP_POST_FILES['userfile']['type'] variable to throw away any files that didn't match a certain type criteria. Whatever the logic, you should either delete the file from the temporary directory or move it elsewhere. @@ -287,8 +262,12 @@ if (is_uploaded_file($HTTP_POST_FILES['userfile'])) { Uploading multiple files - It is possible to upload multiple files simultaneously and have - the information organized automatically in arrays for you. To + Multiple files can be uploaded using different + name for input. + + + It is also possible to upload multiple files simultaneously and + have the information organized automatically in arrays for you. To do so, you need to use the same array submission syntax in the HTML form as you do with multiple selects and checkboxes: @@ -314,30 +293,32 @@ if (is_uploaded_file($HTTP_POST_FILES['userfile'])) { When the above form is submitted, the arrays - $userfile, - $userfile_name, and - $userfile_size will be formed in - the global scope (as well as in $HTTP_POST_FILES ($HTTP_POST_VARS - in PHP 3)). Each of these will be a numerically indexed array of - the appropriate values for the submitted files. + $HTTP_POST_FILES['userfile'], + $HTTP_POST_FILES['userfile']['name'], and + $HTTP_POST_FILES['userfile']['size'] will be + initialized. (as well as in $_FILES for PHP 4.1.0 or + later. $HTTP_POST_VARS in PHP 3. When + register_globals is on, Globals for uploaded + files are also initialized). Each of these will be a numerically + indexed array of the appropriate values for the submitted files. For instance, assume that the filenames /home/test/review.html and /home/test/xwp.out are submitted. In this - case, $userfile_name[0] would - contain the value review.html, - and $userfile_name[1] would - contain the value - xwp.out. Similarly, - $userfile_size[0] would contain - review.html's filesize, and so forth. + case, $HTTP_POST_FILES['userfile']['name'][0] + would contain the value review.html, and + $HTTP_POST_FILES['userfile']['name'][1] would + contain the value xwp.out. Similarly, + $HTTP_POST_FILES['userfile']['size'][0] would + contain review.html's filesize, and so forth. - $userfile['name'][0], - $userfile['tmp_name'][0], - $userfile['size'][0], and - $userfile['type'][0] are also set. + $HTTP_POST_FILES['userfile']['name'][0], + $HTTP_POST_FILES['userfile']['tmp_name'][0], + $HTTP_POST_FILES['userfile']['size'][0], and + $HTTP_POST_FILES['userfile']['type'][0] are + also set.