10

How to select multiple files for upload : enter image description here

Babiker
  • 18,300
  • 28
  • 78
  • 125

9 Answers9

18

This depends on the browser. Newer versions of firefox and chrome support this because they started to implement HTML5 specification. This is the syntax:

<input type="file" multiple=""/>

Firefox >= 3.6, Chrome >= 2, Safari >= 4 support multiple file input.

For older browsers the only good solutions are flash or javascript plugins. Here is a good resource for jquery uploaders ( some support multiple files ): http://creativefan.com/10-ajax-jquery-file-uploaders/

davioooh
  • 23,742
  • 39
  • 159
  • 250
johnlemon
  • 20,761
  • 42
  • 119
  • 178
  • 1
    you meant flash or java plugins probably?. AFAIK javascript won't help you to select multiple files with 1 file element. – Stann May 21 '11 at 14:17
  • Stann: there are javascript plugins that just create a new file element whenever the previous one has a value. – Konerak Sep 04 '12 at 09:45
7

In HTML5 you can set the multiple attribute on <input type="file">. This works in browsers supporting HTML5.

<input type="file" name="upload" multiple="multiple" />

In HTML4 your best bet is Flash or Java Applet. There are 3rd party libs available like Uploadify, SWFupload, JUpload and JumpLoader.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
3

I would definately at this point go with new HTML5 "multiple" attribute:

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

The only viable alternative is FLASH plugins like swfupload.

However - there are multiple prublems with using FLASH for uploads, the main one foor me would be cookie bug:

FLASH plugins don't send cookies correctly. Each browser has it's own cookie storage.FLASH always sends cookies from IE even if you use Google Chrome for example. - result is that you loose cookies and sessions. there is a workaround - but it requires you to send session ID as GET or POST parameters which in turn makes your site vulnerable for session fixation.

Stann
  • 13,518
  • 19
  • 65
  • 73
2

You could also use javascript plugins such as: http://code.google.com/p/noswfupload/

filsterjisah
  • 121
  • 7
1

Use the file input form element more than once, give it a different name and you have multiple upload fields on one page. No need to learn anything else.

Sam Becker
  • 19,231
  • 14
  • 60
  • 80
1
  1. PHP is the back-end, PHP is not the thing which restricts you to use only "one" upload a time
  2. HTML/JavaScript are the front/mid-end which cause the restrictions. (So add HTML to your questions tags)
  3. If you use Flash (AS = ActionScript) you can still have PHP as back-end, as processor which handles the uploaded files.
Julius F
  • 3,434
  • 4
  • 29
  • 44
-1

There is no html/javascript workaround. You would have to look to flash or java to be able to do this.

Peter Smit
  • 27,696
  • 33
  • 111
  • 170
-1

As others have said, you have to use Flash to get multiple uploads. An alternative to uploadify is SWFUpload.

Quasipickle
  • 4,383
  • 1
  • 31
  • 53
-1

Flash is the only option except HTML5.

Chvanikoff
  • 1,309
  • 3
  • 13
  • 21