Forum Moderators: open
I have a contact form on my site that I want to modify so the sender is able to upload several photos to it before they submit it.
I found this via these forums:
<form name="formname" method="post" enctype="multipart/form-data" action="upload.asp">
<input type="file" name="filetoupload">
<input name="Submit" value="Submit" type="submit">
But it only allows for one image and appears to be a separate form altogether - I want the images sent with the rest of the form, not separately.
Does anyone know where I can find an example of a form that allows the upload of mulitple images and lets the sender submit them with the entire form?
Thanks!
## All query data is stored in %qs from a standard read/parse.
## Maximum number of pics allowed for upload?
$uploads_allowed = 5;
## If 0 images is not possible just start at 1.
if (! $qs{'num_pics'}) {
$form = qq¦
<form method="post" action="yourscript">
Please enter how many pics you will upload (if none, select 0.)
<select name="num_pics">
¦;
for $i (0..$uploads_allowed) {
$form .= qq¦<option value="$i">$i</option>\n¦;
}
$form .= qq¦
</select>
<input type="submit" value="Continue">
</form>
¦;
}
else {
$form = qq¦
<form method="post" enctype="multipart/form-data" action="yourscript">
<input type="hidden" name="num_pics" value="$qs{'num_pics'}">
¦;
## if number of pics is zero, it will do nothing here.
for $i (1..$qs{'num_pics'}) {
$label = 'File ' . $i;
$obj_name = 'file_' . $i;
$form .= qq¦$label: <input type="file" name="$obj_name"><br>\n¦;
}
$form .= qq¦
<input type="submit" name="submitButton" value="Upload">
</form>
¦;
When submitted on the server side, you would do the same sort of looping to figure out which fields contain file data.
I asked my webhost and he said his server doesn't have any Microsoft code on it or anything that even smells of Microsoft, so the .asp code in my original post wouldn't work anyway. He suggested finding a precanned php script so I am going to have a looksee for that, too.
Thanks again! :o)