Uploading Multiple Files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Uploading Multiple Files

Post by kendall »

Hello,

Can i upload multiple files?

i have a form with the file fileds id = file[1], file[2], file[3] etc...

im trying to access the $_FILES['file'][1]['name'] but i dont get anything

Kendall
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

try this:
A) <input type="file" name="localfile[]"> (if you are using a loop to create the lines)
B) $_FILES['localfile']['name'][$idx] // put the counter at the end of the variable
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Uploading Multiple Files

Post by kendall »

thanks Deven
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

oh just one more thing... at the end of it all i do a unlink($_FILE['file']['tmp_name']); but i get an error...what gives? are temp files automatically delete after a move_uploaded_file()?
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

yup - move_uploaded_file actually moves the file - it doesn't copy it and move the copy (unlike copy).
it will only work on files uploaded through the $_FILES array as well, thus is more secure than copy+unlink.
Post Reply