FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Upload files in "web-email site" style

 


rudi
Anyone knows script (in php) or method how to implement in web form multiple files upload?
I know tradition method.

Example: I have now 4 input boxes with 4 browse button besides:
This approach is quite unflexible. Sometimes will be too few and sometimes too much boxes.

I would like make it like in web-email sites (eg. gmail).
You have one input box with browse button and than if you want to add a new file, you click eg. 'add another one', and than new box under the old one appear.

Some advicses will be really appreciated:)
SlowWalkere
I haven't used gmail and haven't seen that particular set up for uploading files, but I've used a similar method to automatically adjust forms for the amount of data that needs to be inputted. This may not be exactly what you wanted, but perhaps you could tailor it to your needs.

When the user goes to the first form there are several drop down lists asking how many fields there should be. This stuff posts to the second page, which generates the form based on the input. It would look something like this...

Code:

$numfields = $_POST['numfields'];
$num = 1;

while ($num <= $numfields)
{
    $fieldname = "fieldname" . $num;
    echo "<input type=\"file\" name=\"$fieldname\" />";
    $num++;
}


Or if you simply want a link that says "Add another field," you can use the same code to generate the form. Have the link point back to the same page and pass a value to "$numfields" in the url. If $_GET['numfields'] isn't set, the page should default to $numfields = 1, and have the link send $_GET['numfields'] + 1.

Good luck,
- Walkere
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.