[nycphp-talk] multiple file uploading
Greg Faber
greg at click3x.com
Tue Mar 2 10:49:16 EST 2004
Good morning people,
Just a quick question, for which I'd like a quick answer.
When I wrote (uh... copy/pasted) my script to upload a file, I included
the usual safeguards they mention in all the books: check to see if
something is uploaded, verify file size != 0 and verify file type. Now,
let's say I want to be able to upload 5 files at a time, must I verify
every possible combination of uploaded/not-uploaded file or is there a
function out there that was made specifically to handle this? (if there
isn't I'll just bite the bullet and do it, I'm just thinking that this
is so common someone MUSt have done it before, right?) IF I don't make
sense, this is what I mean:
< example with only 1 file upload at a time>:
if ($_FILES['userfile']['tmp_name']=="") {
echo "no file uploaded";
exit;
}
if ($_FILES['userfile']['size']=="0") {
echo "file size is 0";
exit;
}
< 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.
Grazie,
Greg
More information about the talk
mailing list