Facebook-style multiple image upload

2019-04-10 05:41发布

问题:

Facebook has the ability to select multiple images in the file browser in its upload feature.

Can anyone explain how this is achieved?

I'd like to do something similar in jquery without the use of a flash widget.

回答1:

The HTML5 File API enables you to do it natively. Basically you add the multiple="multiple" attribute to the file upload control:

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

Disadvantage: Only runs in modern browsers like Firefox, Chrome, Safari. IE, even version 9 does not support this multiple upload.

Otherwise, you have to rely on some Flash or Java upload component.

(Edit: Changed to multiple="multiple", thanks to Ms2ger)



回答2:

The best and easiest jQuery-based multiupload scripts (IMHO):

http://www.uploadify.com/
http://www.uploadify.com/demos/

free and open source



回答3:

Instructions on how to include jQuery File Upload with Rails setup https://github.com/blueimp/jQuery-File-Upload/wiki/Rails-setup-for-V5/35cca0e5e21b5c8fb29b89e9675314907ac1a464

(note: this question was originally answered 3 years ago, the above link may have inaccurate instructions for recent versions of the referred gems/libraries, but may be easy for someone to follow and fix whatever have changed).



标签: file-upload