Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys,
Up to now I've needed mostly single file uploading via php, and there is plenty of examples on the net. I had no problem using and adapting those. However, when trying the multiple file case, I've run into strange problems, even with adapted public code.
For example having a form like the one below:
[syntax="html"]
<form method="post" action="http://www. .... /upload.php" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
<p class="sectionheader">Add New Event</p>
<a href="javascript:window.history.back();">GO BACK (w/o making changes)</a><br><br>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="newsheader" valign="top">Main Picture 1 (only 514x396 pixels, default):</td>
<td><input name="uFiles[]" type="file" class="box" size="60"></td>
</tr>
<tr>
<td class="newsheader" valign="top">Main Picture 2 (only 514x396 pixels):</td>
<td><input name="uFiles[]" type="file" class="box" size="60"></td>
</tr>
<tr>
<td class="newsheader" valign="top">Main Picture 3 (only 514x396 pixels):</td>
<td><input name="uFiles[]" type="file" class="box" size="60"></td>
</tr>
<tr>
<td class="newsheader" valign="top">Main Picture 4 (only 514x396 pixels):</td>
<td><input name="uFiles[]" type="file" class="box" size="60"></td>
</tr>
<tr>
<td class="newsheader" valign="top">Main Picture 5 (only 514x396 pixels):</td>
<td><input name="uFiles[]" type="file" class="box" size="60"></td>
</tr>
<tr>
<td class="newsheader" valign="top">Main Picture 6 (only 514x396 pixels):</td>
<td><input name="uFiles[]" type="file" class="box" size="60"></td>
</tr>
</table>
<br>
<input type="Submit" name="submit" value="Enter">
<input type="Reset" name="reset" value="Reset"></p>
</form>Code: Select all
foreach ($_FILES["uFiles"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["uFiles"]["tmp_name"][$key];
$name = $_FILES["uFiles"]["name"][$key];
move_uploaded_file($tmp_name, "./$name");
} else {
print "$error " . "\r\n";
}
}Any suggestions? What am I doing wrongly?
Thanks, Cristian
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]1.[/b] Select the correct board for your query. Take some time to read the guidelines in the sticky topic.[/quote]