[nycphp-talk] multiple file uploading
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Tue Mar 2 10:52:55 EST 2004
On Tue, 2 Mar 2004, Greg Faber wrote:
> < example with only 2 files upload at a time>:
> if ($_FILES['userfile_1']['tmp_name']=="" &&
> $_FILES['userfile_2']['tmp_name']=="") {
> echo "no file uploaded";
> exit;
> }
> if ( ($_FILES['userfile_1']['size']=="0" &&
> $_FILES['userfile_1']['tmp_name']!="" ) ||
> ($_FILES['userfile_2']['size']=="0" &&
> $_FILES['userfile_2']['tmp_name']!="" )) {
> echo "file size is 0";
> exit;
> }
>
>
> If you have the possibility to upload 5 files at the same time, looks
> like things can get pretty hairy. Is it just stupid to allow users to
> upload multiple files at the same time? Just some quick thoughts
> please.
Try using a foreach loop over the $_FILES array:
foreach($_FILES as $file) {
if ($file['size'] == 0 || $file['tmp_name'] != "") {
echo "file size is 0";
exit;
}
}
-adam
--
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!
More information about the talk
mailing list