Jump to content

help with multiple upload


hobojjr

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?
Link to comment
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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.