-1

I am doing this with single files uploads using

<input type="file" name="comment_img1">
<input type="file" name="comment_img2">
<input type="file" name="comment_img3">
<input type="file" name="comment_img4">
<input type="file" name="comment_img5">

However, I am having trouble doing uploading more than one at a time.

For example, I'd like to be able to select a series of images, then upload them to the server, all at once.

It would be great to use a single file input control, if possible.

Does anyone know how to accomplish this? Thanks!

Antony Star
  • 37
  • 1
  • 8
  • Directly you can't do multiselect like this. You might check this: https://blueimp.github.io/jQuery-File-Upload/ – unalignedmemoryaccess Jun 14 '17 at 11:33
  • _"It would be great to use a single file input control, if possible."_ - then it would be great if you could type `single file input control multiple` or similar into google. – CBroe Jun 14 '17 at 11:33
  • 2
    Possible duplicate of [Multiple file upload in php](https://stackoverflow.com/questions/2704314/multiple-file-upload-in-php) – PEHLAJ Jun 14 '17 at 12:13

4 Answers4

0

You can't do multiselect with single input without javascript directly.

However, you might consider using a library for this.

https://blueimp.github.io/jQuery-File-Upload/ This one is very powerful.

unalignedmemoryaccess
  • 7,246
  • 2
  • 25
  • 40
0

i think your question is already answered here: How to upload multiple files using one file input element

Greetings from Germany

0

you can use multiple attribute for input tag

<input type="file" name="images" multiple>

so it will allow you to select multiple files and on the server side you will get an array eg: $_FILES[images]

then you can loop through this array and upload them one by one

if you still have any confusion see this question Multiple file upload in php

0

You can't select more than one file in a single input file type without using multiple attribute of it.

Use of multiple in input type="file" is more easy in comparison of your code. so just use the following :

<input type="file" name="whatever_you_want[]" multiple="multiple" />

after submit your form data, you will get an array of it like

$_FILES['name_of_your_input_file_type'];

and after that you can use foreach loop to get images in sequence.

Ankit Singh
  • 1,477
  • 1
  • 13
  • 22