ayok Posted December 24, 2007 Share Posted December 24, 2007 Hi, I've made a multiple images upload php scripts. It will show 5 upload field, and if it's submitted and processed, it will show the uploaded images with input text field to fill in the title of the pics. However, when it shows the uploaded pics, it always show one field more which is empty. So it shows 6 field, not five. Moreover, If I only upload 3, the rest still shows up. Thus, there are 3 empty fields. The result, I got 3 empty fields on my database (which I need to delete). Here is my multiple upload script: <?php echo"<form enctype='multipart/form-data' action='newpics.php' method='POST'>"; for($i=0;$i<5;$i++){ $no=$i+1; echo "File $no: <input type='FILE' name='fupload[]'><br><br>"; } echo "<br><input type='SUBMIT' value='Add'"; echo "</form>";?> And it's processed and shown in newpics.php: <?php $fupload = $_FILES['fupload']['tmp_name']; $fupload_name = $_FILES['fupload']['name']; $fupload_type = $_FILES['fupload']['type']; echo "Uploaded files:<br><br>"; $images=count($fupload); $i=0; echo "<table>"; while($i <= $images) { $direktori_file = "../../gallery/images/original/$fupload_name[$i]"; ...... resize scripts........ echo "<form action='inputdata.php' method='GET'><tr><td><img src='$thumbnail'></td><td rowspan=2><INPUT TYPE=TEXT SIZE=30 NAME= descript[]></td></tr>"; echo "<tr><td>$fupload_name[$i]<input TYPE=hidden name=fupload_name[] value='$fupload_name[$i]'></td></tr>"; $i++; } echo "</table><INPUT TYPE=SUBMIT VALUE=Add Info></form>";?> Could someone tell me how can I exclude the fields that I don't need? Thank you, ayok Quote Link to comment https://forums.phpfreaks.com/topic/83030-solved-multiple-uploads-problem/ Share on other sites More sharing options...
shocker-z Posted December 24, 2007 Share Posted December 24, 2007 because your array will count 5 and 0 1 2 3 4 5 is 6 counts not 5 You need while($i < $images) Regards Liam Quote Link to comment https://forums.phpfreaks.com/topic/83030-solved-multiple-uploads-problem/#findComment-422328 Share on other sites More sharing options...
ayok Posted December 24, 2007 Author Share Posted December 24, 2007 Ah... Thank's a lot shocker-z! I missed that! Thank you, ayok Quote Link to comment https://forums.phpfreaks.com/topic/83030-solved-multiple-uploads-problem/#findComment-422329 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.