note 39516 modified in features.file-upload.multiple by vrana
| From: | vrana@php.net | Date: | Sat, 31 Jan 2004 19:08:35 +0000 |
| Subject: | note 39516 modified in features.file-upload.multiple by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-64483@lists.php.net to get a copy of this message | ||
Why even bother with uploading multiple files into an array? If you are expecting files for
particular reasons, just name each upload differently. So for example, your HTML code might look
like this:
<FORM ACTION="upload.php" METHOD="POST"
ENCTYPE="multipart/form-data">
Send these files:<BR>
<INPUT TYPE="FILE" NAME="firstfile" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="secondfile" SIZE="50"><BR>
<INPUT TYPE="SUBMIT">
</FORM>
And in 'upload.php' have the following code:
<?PHP
$uploaddir = "uploads/";
$uploadfile1 = $uploaddir . $_FILES['firstfile']['name'];
$uploadfile2 = $uploaddir . $_FILES['secondfile']['name'];
if (!move_uploaded_file($_FILES['firstfile']['tmp_name'], $uploadfile1)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
if (!move_uploaded_file($_FILES['secondfile']['tmp_name'], $uploadfile2)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
?>
--was--
Why even bother with uploading multiple files into an array? If you are expecting files for
particular reasons, just name each upload differently. So for example, your HTML code might look
like this:
<FORM ACTION="upload.php" METHOD="POST"
ENCTYPE="multipart/form-data">
Send these files:<BR>
<INPUT TYPE="FILE" NAME="firstfile" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="secondfile" SIZE="50"><BR>
<INPUT TYPE="SUBMIT">
</FORM>
And in 'upload.php' have the following code:
<?PHP
$uploaddir = "uploads/";
$uploadfile1 = $uploaddir . $_FILES['firstfile']['name'];
$uploadfile2 = $uploaddir . $_FILES['secondfile']['name'];
if (!move_uploaded_file($_FILES['firstfile']['tmp_name'], $uploadfile1)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
if (!move_uploaded_file($_FILES['secondfile']['tmp_name'], $uploadfile1)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
?>
http://www.php.net/manual/en/features.file-upload.multiple.php