Jump to content

Recommended Posts

Greetings everyone, and thank you to the mods for allowing my account so rapidly! For a week or so now I've been trying to find information on how file uploads are stored in PhP. I'm creating an html photo upload form. I've figured everything out, except for how to handle the files. When you have:

<form action="store.php" method="post" enctype="multipart/form-data">    <input type="file" name="images" multiple="multiple"></form>

I know that for a single file $_FILES["images"]["tmp_name"] is where the file would be temporarily stored on the server. However, only one image is being stored here, not the two or three that I'm selecting using the upload form. Any assistance or tips would be greatly appreciated!

Link to comment
Share on other sites

For the name attribute, have it like the following: name="images[]" To note: the multiple attribute for the input element is new to HTML5 Then when you go to retrieve everything in PHP, you can do so like the following for example, for the name:

$firstImgName =  $_FILES['images']['name'][0];$secondImgName = $_FILES['images']['name'][1];

Type would be like so:

$firstImgType =  $_FILES['images']['type'][0];$secondImgType = $_FILES['images']['type'][1];

etc..

Link to comment
Share on other sites

"For the name attribute, have it like the following: name="images[]" To note: the multiple attribute for the input element is new to HTML5"-Don E(Sorry, I keep getting an error saying "The number of opening quote tags does not match the number of closing quote tags.") This has worked wonders!Since the multiple attribute is new to HTML5, how were multiple-file uploads handled previously? The only way that I can think is using Javascript to add more html file inputs, but then the file browser only allows the selection of one file at a time. birbal,I had read through a lot of the Php manual, but I was unable to figure out how to upload multiple files without having to go through the file browser several times. Only once, using shift+click or ctrl+click. Thank you!

Link to comment
Share on other sites

(Sorry, I keep getting an error saying "The number of opening quote tags does not match the number of closing quote tags.")
Where's it say that exactly? Posting what you have so far would be a good idea.
Link to comment
Share on other sites

Where's it say that exactly? Posting what you have so far would be a good idea.
It said that on these forums when I tried to quote your post. Edit: It's working now. Probably just a browser hiccup on my end. Edited by djryan
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...