Re: multi file upload in php4

From: Date: Mon, 05 Jun 2000 18:49:25 +0000
Subject: Re: multi file upload in php4
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1080@lists.php.net to get a copy of this message
> 1) userfile does not appear as part of HTTP_POST_VARS array Look in $HTTP_POST_FILES > 2)userfile_name, userfile_size and userfile_type arrays do not exist after > uploading , and the contents of userfile[] seem to go something like this: > > for the file foo.gif : > userfile[0] = foo.gif - (seems ok - this is the name of the file) > userfile[1] = image/gif - (seems to be the file type) > userfile[2] = /tmp/php1Nrzxb - (seems to be the location of the temp file) > > for multiple files this pattern continues - userfile[3] , [4], and [5] would > be the name, type and temp location of the second file in the array. This > is inconsistent with the documentation. > > Is this the way php4 handles the uploads? and is there a way to get the > filesize of the uploaded file? > > FWIW: server is php4 compiled on Linux, using netscape 4.7 client from a > macintosh I cleaned this up in PHP 4 CVS and it will be part of 4.0.1. For multiple file uploads you can now do make the userfile part an array. ie. <INPUT NAME="ufile[0]" TYPE="file"> <INPUT NAME="ufile[1]" TYPE="file"> Or even <INPUT NAME="ufile[]" TYPE="file"> <INPUT NAME="ufile[]" TYPE="file"> This would set the following: HTTP_POST_FILES['name'][0] HTTP_POST_FILES['name'][1] HTTP_POST_FILES['type'][0] HTTP_POST_FILES['type'][1] HTTP_POST_FILES['tmp_name'][0] HTTP_POST_FILES['tmp_name'][1] HTTP_POST_FILES['size'][0] HTTP_POST_FILES['size'][1] $ufile['name'][0] $ufile['name'][1] $ufile['type'][0] $ufile['type'][1] $ufile['tmp_name'][0] $ufile['tmp_name'][1] $ufile['size'][0] $ufile['size'][1] $ufile_name[0] $ufile_name[1] $ufile_type[0] $ufile_type[1] $ufile[0] /* holds the tmp_name */ $ufile[1] $ufile_size[0] $ufile_size[1] Probably overkill, but it should do everything everybody ever needs to do and is pretty much backward compatible with the PHP 3 way of doing things. Might be a good idea for one of the documentation guys to add this to the docs. Note that it is only effective as of PHP 4.0.1. -Rasmus

« previous php.general (#1080) next »