Jump to content


Photo

help with multiple upload


  • Please log in to reply
1 reply to this topic

#1 hobojjr

hobojjr
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 04 September 2006 - 07:10 PM

hi

I found this code to upload multiple files

foreach ($_FILES["pictures"]["error"] as $key => $error) {
	   	$name = $_FILES["pictures"]["name"][$key];
		if ($error == UPLOAD_ERR_OK) {
	       $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
	       move_uploaded_file($tmp_name, $uploadDir.$name);
....

it works fine for 1-5 small files but when i try to upload 10 photos i get invalid agrument in foreach call...

anyone know whats going on?

#2 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 04 September 2006 - 09:37 PM

Have a shot at this..  this is a script i found a while ago though havent tested..  you may have to edit it a little bit but should give you a decent start...  Its totally different than what you've got an has 0 error checking..  but that could be changed..  i hope this helps even the slightest..

upload form:
<?php
<table width = "500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>Multiple Files Upload</strong></td>
</tr>
<tr>
<td>Select File: <input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
</tr>
<tr>
<td>Select File: <input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
</tr>
<tr>
<td>Select File: <input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

?>

processing script:

<?php
echo $HTTP_POST_FILES['ufile']['name'][0];
echo "<br>";
echo $HTTP_POST_FILES['ufile']['name'][1];
echo "<br>";
echo $HTTP_POST_FILES['ufile']['name'][2];
echo "<br>";
?>

Something along those lines should help..  you might have to play with it a bit to get it to have the functionality you want...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users