Jump to content

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

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.