Page 1 of 1

how do i upload more than one image at a time

Posted: Sat Aug 28, 2010 11:46 am
by adsegzy
please i have this more that i want to use in uploading 5 images at a time, but i don't know how to upload the files into my upload folder;

Code: Select all

<form action="<?php echo $_SESSION['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
              <table width="300" border="0" align="center" cellpadding="5" cellspacing="0">
                <tr>
                  <td align="center"><label>
                    <input type="file" name="file" />
                  </label></td>
                </tr>
                <tr>
                  <td align="center"><label>
                    <input type="file" name="file2" />
                  </label></td>
                </tr>
                <tr>
                  <td align="center"><label>
                    <input type="file" name="file3" />
                  </label></td>
                </tr>
                <tr>
                  <td align="center"><label>
                    <input type="file" name="file4" />
                  </label></td>
                </tr>
                <tr>
                  <td align="center"><p>
                    <label>
                    <input type="file" name="file5" />
                    </label>
                  </p>
                  </td>
                </tr>
              </table>
              <p align="center">
                <label>
                <input type="submit" name="Submit" value="Upload" />
                </label>
              </p>
            </form>
i tried using this move to folder code;

Code: Select all

$file_name = ($_FILES["file"]["name"]);
	$random_digit=rand(00000,99999);
	$new_file_name=$random_digit . $imageResized;
	
    if (($_FILES["file"]["name"]!="") && file_exists("../upload/" . $new_file_name))
      {
      echo "<span class='style3'>Please reupload the Picture.</span>";
      }
    else
      {
      	move_uploaded_file($_FILES["file"]["tmp_name"],
		"../upload/" . $new_file_name);
		$path2= "../upload/" . $new_file_name;
		
but someone advised i put it in an array but i don't know how to go about that. please ow can i do this or which other less stress way can i do this.

regards

Re: how do i upload more than one image at a time

Posted: Sat Aug 28, 2010 7:29 pm
by Jonah Bron
Use the code you have, just put it inside a loop that runs through $_FILES.