By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Unable to upload multiple files

100+
P: 114
Dear Friends,

I am trying to upload multiple files. But I can't find why it is not working fine. Here is the code.........

numfile.php

[HTML]<form method="POST" action="fileupload.php">
<p align="center">
<font face="Verdana" size="2">Number of files</font>
<input type="text" class="text" name="numfiles" size="3" maxlength="3"><br>
<br>
<input type="submit" value="Submit" name="submit" style="font-family: Verdana; font-size: 8pt; font-weight: bold; border: 1px solid #666666; padding: 2"></p>
</form>[/HTML]


fileupload.php

[PHP]$numoffile = $_POST['numfiles']; //value taking from numfile.php

$file_dir = "files/";

if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['myfiles']['name'][$i];
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
$j++;
}
}
}
if (isset($j)&&$j>0) print "<center><font family='verdana' size='2' color='green'>Your file(s) has been uploaded.</font><br>";
print "<p><h3 style='font-family:verdana;color:green;text-align:center'>Upload Files</h3></p><form method='post' enctype='multipart/form-data'>";
for($i=0;$i<$numoffile;$i++) {

$num = $i+1;
print "<center><span style='font-family:verdana;font-size:10pt'>File $num </span> <input type='file' name='myfiles[]' size='30'><br>";
}
print "<p align='center'><input type='submit' name='action' value='Upload'></p>";
print "</form>";[/PHP]


Please help me out where is the error.........

Thanks
Deepak
May 3 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.