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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...