Jump to content

[SOLVED] Multiple Uploads Problem


ayok

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/83030-solved-multiple-uploads-problem/
Share on other sites

Archived

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

×
×
  • 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.