I'm playing around with an image uploader so I can send some images to a server. I have it working properly with one field, but I'm not sure how to add multiple fields and then get all of the images to go at one time.
Here's the code I'm using right now:
<?php
if ($_REQUEST[completed] == 1) {
$newname = uniqid("file").".jpg";
move_uploaded_file($_FILES['mailfile']['tmp_name'],
"uploads/$newname");
} ?>
<html>
<head><title>Uploader</title></head>
<body><h1>Uploader</h1>
<?php if ($_REQUEST[completed] != 1) { ?>
<b>Please upload images below</b><br>
<form enctype=multipart/form-data method=post>
<input type=hidden name=MAX_FILE_SIZE value=1500000>
<input type=hidden name=completed value=1>
Choose files to send: <br />
<input type=file name=mailfile><br />
<input type=submit value="upload"></form>
<?php } else { ?>
<b>Upload Successful!</b>
<?php } ?>
</body></html>
Can anyone tell me how to have multiple fields with only one submit button so they all get uploaded at once?
how can I get multiple input fields to work with this form?
Moderator: General Moderators
-
wlandymore
- Forum Newbie
- Posts: 2
- Joined: Wed Jun 25, 2008 10:10 pm
Re: how can I get multiple input fields to work with this form?
http://www.google.com/search?q=php+mult ... le+uploads
Notice the brackets. Just add more of this line for how many you want to be able to upload.
Now you need to have php loop threw the files, because mailfile is now going to be an array.
Notice the brackets. Just add more of this line for how many you want to be able to upload.
Code: Select all
<input type="file "name="mailfile[]"> -
wlandymore
- Forum Newbie
- Posts: 2
- Joined: Wed Jun 25, 2008 10:10 pm
Re: how can I get multiple input fields to work with this form?
thanks for the pointer. 
perfect.
perfect.