multiple file uploads
| From: | David Drexler | Date: | Thu, 20 Jul 2000 04:23:11 +0000 |
| Subject: | multiple file uploads | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-7373@lists.php.net to get a copy of this message | ||
I have an application where I need to have multiple file uploads through a
single form. There are several categories of uploads, and multiple entries
within each. I want each input to have a different variable name (for
validation) and the whole shmear to be referenced within arrays.
The manual (http://www.php.net/manual/feature-fileupload.multiple.php)
doesn't give any way to do that. The answer seems to be variable
variables. I hope someone finds the following code fragment useful.
dd
<?
for( $x=0; $x<3; ++$x ) {
$f="up".$n ;
$a=${$f}[0] ;
printf( "upload[%d]=%s<p>", $x, $a ) ;
$n=$f."_name" ;
printf( "upload_name[%d]=%s<p>", $x, ${$n}[0] ) ;
$n=$f."_size" ;
printf( "upload_size[%d]=%s<p>", $x, ${$n}[0] ) ;
echo "...................<p>" ;
}
?>
<a href="<? echo $PHP_SELF ; >">reload</a><p>
<form name="composeform" method="POST"
enctype="multipart/form-data" action="ul.php3">
<table>
<tr><td><input name="up0[]" type="file"></td></tr>
<tr><td><input name="up1[]" type="file"></td></tr>
<tr><td><input name="up2[]" type="file"></td></tr>
</table>
<input type="submit" value="you send me, baby"></form>