Hi,

I recently added a note to the 'Uploading multiple files' page and made a tiny
little mistake. Is it possible for you to edit it for me (since there is no
editing procedure)? My note is:

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);
   }

?>



It is possible for you to change the second 'if' statement from:

   if (!move_uploaded_file($_FILES['secondfile']['tmp_name'], $uploadfile1)) {

to

   if (!move_uploaded_file($_FILES['secondfile']['tmp_name'], $uploadfile2)) {

???


Thank you,
Peter

Reply via email to