hi guys,
I am developing a website, and it needs people to upload images. I can write code for single upload but not multiple, please help.

Thanking you in advance!

Use a file area like this

<input type="file" name="upload[]" >

then in you php script

foreach($_FILES['upload'] AS $file)
{
//HERE YOU DO YOUR FILE SAVING
//For the file array
}

Looping is the way to go as Menster has just shown you here. in your html add as many file input fields as you want but name them all as upload[] so that PHP will take the name upload as an array when it is posted.
You can then loop through the array as you do your saving. I'm just explaining Menster's code

/*Happy coding*/

Here is an upload example I created a day or two ago. It needs to be modified a bit, but you get the basic idea.

Its pretty secure, making it so people can't upload scripts to the server and run them.

http://www.daniweb.com/forums/post905365-3.html

php code

if(isset($_POST['submit']))
	{
	   $video_title = $_POST['photo_title'];
	   $description = $_POST['description'];
	   
	
	   $MAX_SIZE = 2097152; 
	   
	   $filename = $_FILES['photo']['name'];
	   $filesize = $_FILES['photo']['size'];
	   if($filename!='')
	   {
	   
	   if( $filesize > $MAX_SIZE)
	   {
	        $err_msg = "<font color='red'>Your photo file size should not be exceed </font>";	 
			$filename =$_POST['hidden_file']; 
	   }
	   else
	   {
	   
			if(is_file("../photo/".$_POST['hidden_file']))
		   {
			  unlink("../photo/".$_POST['hidden_file']);
		   
		   }
	   
	   $filecontent = $_FILES['photo']['tmp_name'];
	   move_uploaded_file($filecontent,"../photo/".$filename);
	   }
	   
	   
	   }
	   else
	   {
	      	$filename =$_POST['hidden_file']; 
	   
	   }
	   
	  /*****VIDEO UPLOAD SECTION******/
	  
	   $sql = "UPDATE ".PHOTO." SET
	  								photo_title = '$photo_title',
									description = '$description',
									photo_file = '$filename',
									created_date = NOW()";
	  mysql_query($sql);
	   
	
	}
	
	$select = "SELECT * FROM ".photo;
	$read = mysql_query($select);
	$row=mysql_fetch_object($read);
	$title = $row->photo_title;
	$description = $row->description;
	$video_file = $row->photo_file;
	
	
?>

html code


     <table width="100%" height="500" border="0" cellspacing="0" cellpadding="0" >
				  
				  <tr>
					<td align="center" valign="top">
					  
					   <table width="100%" border="0" cellspacing="5" cellpadding="5">
                      <tr> 
                        <td width="30%"><h4>:: Photo Gallery</h4></td>
                        <td>&nbsp;</td>
                        <td width="70%"><?php echo $err_msg;?></td>
                      </tr>
                      <tr> 
                        <td align="right" class="smallfontbold">Photo Title</td>
                        <td>:</td>
                        <td><input type="text" name="photo_title" id="video_title" value="<?php echo $title;?>"></td>
                      </tr>
                      <tr> 
                        <td align="right" valign="top" class="smallfontbold">Photo 
                          Description</td>
                        <td>:</td>
                        <td valign="top"><textarea name="description" cols="4" rows="5" id="description" class="mceAdvanced"><?php echo $description;?></textarea></td>
                      </tr>
                      <tr> 
                        <td align="right" valign="top" class="smallfontbold">Photo 
                          Upload</td>
                        <td valign="top">:</td>
                        <td><input type="file" name="photo" id="photo" onKeyPress="return false;" >
						   <input type="hidden" name="hidden_file" value="<?php echo $photo_file;?>">
						</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>
						<div> </div>
						</td>
                      </tr>
                      <tr> 
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td><input type="submit" name="submit" value="SUBMIT"></td>
                      </tr>
                    </table>

					
					</td>
				  </tr>
				</table>

give me codes for uploading an image using php

How to upload multiple images ? through php,html and if neccessary javascript.
when i click on upload button it is not selecting more than one image

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.