0 Replies - 2276 Views - Last Post: 02 September 2005 - 08:53 PM Rate Topic: -----

#1 lilygrace  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 103
  • Joined: 17-August 05

Uploading Multiple Images

Posted 02 September 2005 - 08:53 PM

I need some help here with my code. I don't know where I got it wrong. I'm doing a gallery for my client's website and the format that photobucket.com has is my based.

here's my code (choosing how many images you want to upload)
  	<form method="post" action="gallery.php?mode=upload">
              <td width="26%" valign="top">
                <strong>Upload Image:</strong>
</td>
              <td width="74%" valign="top"><p>
                  <select name="count">
                    <option>Submit Multiple Photos</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                  </select>
              </p>
                <p>                    <input type="submit" name="Submit" value="Submit">
                </p></td>
     </form>


code: gallery.php?mode=upload (the forms)
 <? if ($mode == "upload")
  	{?>
            <tr bgcolor="#60060F">
              <td colspan="2" valign="top" class="title"><strong>Administration Control Panel &gt;&gt; Photo Gallery &gt;&gt; Upload Image </strong><strong></strong></td>
            </tr>
            <tr>
              <td valign="top"><strong>Upload Image:</strong> </td>
              <td valign="top"><form method="post" action="gallery.php?mode=submitimages" enctype="multipart/form-data"><?
     $i = $_POST["count"];
     for ($x = 1; $x <= $i; $x++)
     {
      ?>
     <p>Title: <input type="title" name="title<?=$x;?>"><br />
     Picture: <input type="file" name="image<?=$x;?>"></p>
      <? } ?>
      <input type="submit" value="Upload">
      </form>
      </td>
            </tr>
  	<? } ?>


and the process in uploading
if ($mode == "submitimages")
  	{
  	$c = 0;
  	while ($_POST["title".$c])
  	{
  	$title = mysql_escape_string($_POST["title".$c]);
  	$pic = $_POST["image".$c];
  	$x = $c + 1;
  	if (empty($_POST["title".$c]))
    {
  	?>
            <tr bgcolor="#60060F">
              <td colspan="2" valign="top"><span class="title"><strong>Administration Control Panel &gt;&gt; Photo Gallery &gt;&gt; Upload Image </strong><strong></strong></span></td>
              </tr>
            <tr>
              <td valign="top"><b><font color=#CC0000>Error:</font> Missing Field</b></td>
            </tr>
  	<?   
  	include ("./functions.php");
  	$rest3 = rest3();
  	echo "$rest3";
  	include ("./footer.php");
  	exit();
  	} //end of the validation?>
    <tr bgcolor="#60060F">
              <td colspan="2" valign="top"><span class="title"><strong>Administration Control Panel &gt;&gt; Photo Gallery &gt;&gt; Upload Image </strong><strong></strong></span></td>
              </tr>
            <tr>
              <td valign="top">
    <?
     // File Upload Settings
  	$destination_folder = "home/impactun/public_html/gallery/upload_images/"; // is our destination folder
  	$newimagename = $destination_folder.$_FILES['image'.$c]['name'];
  	
  	if (file_exists($newimagename)) // file exists
    	{
    	echo 'File Exist! Kindly rename your file';
    	include ("./functions.php");
    	$rest3 = rest3();
    	echo "$rest3";
    	include ("./footer.php");
    	exit();
    	}
  	if (move_uploaded_file($_FILES['image'.$c]['tmp_name'], $newimagename))
    {
    echo "<p>Success, Your file has been uploaded as".$newimagename."</p>";
    }
    $c++;
  	} // end of the while statement
      ?></td>
            </tr>
  <? 
  } ?>


EDIT: Sorry about this.. I GOT IT ALREADY! Thanks!

This post has been edited by lilygrace: 03 September 2005 - 03:20 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1