Posting multiple files

HI guys
Can I pass multiple photos like below and then pull them

             <form method="post" action="addgallery.php" enctype="multipart/form-data">
<h3>Add Event</h3>

	
	<table cellspacing=15>

 <?
    $arr = array(1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25);
foreach ($arr as &$value) {
    $value = $value * 2;

    
    ?>
    
    
    <tr><td>Photo</td><td><input type=file  size=60 name=photo[]><br /><br /></td></tr>

			<? } ?>																	
		
<tr><td></td><td><input type=submit name=submit value="Add Gallery"></td></tr>
	</textarea>



</table>


</form>

Then when the form is submitted I try to call it like this but it is not working.

$photo = stripslashes($_POST[photo][name]);
echo"$photo / ";


if($photo!='') {

foreach($_POST['photo'] as $key=>$team_id){



$filename = $_POST['photo'][$key];


if($_FILES['photo']['name']!=''){
 $photo=$_FILES['photo']['name'];
 $phototmp=$_FILES['photo']['tmp_name'];
upload_file();
}



I think if you do a var_dump of $_FILES after posting you’ll see what you’re doing wrong.

Also, you can replace


$arr = array(1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25);

with


$arr = range(1,25);

easier to read :slight_smile:

http://www.php.net/manual/en/features.file-upload.php
http://www.php.net/manual/en/features.file-upload.post-method.php