Jump to content

Archived

This topic is now archived and is closed to further replies.

hobojjr

help with multiple upload

Recommended Posts

hi

I found this code to upload multiple files

[code]
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);
....[/code]

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?

Share this post


Link to post
Share on other sites
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:
[code]
<?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>

?>
[/code]

processing script:

[code]
<?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>";
?>
[/code]

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.