When you upload files to attach to a gmail message it lets you select multiple files from the browser file selector to attach at once. How could I build the same effect with a Django/Python/jquery site? I want to let the user upload multiple files at once (if you hold down开发者_开发问答 ctrl gmail file selector can select multiple files.)
I recommend you using a jQuery plugin called Uploadify
This is only supported in the latest browsers (read: not IE), but to enable the ability to select multiple files from a single file input field is done by adding multiple="multiple"
to the input
element, like so:
<input type="file" multiple="multiple" />
To gracefully degrade this, you can either just not allow multiple file uploads at once for unsupported browsers, or sniff if that capability is available using a utility like modernizr, and adjust accordingly. There are a few different jQuery plugins for mutiple file uploads without the multiple="multiple"
features, and from what I can tell they all mostly revolve around the idea of dynamically adding new file fields as the old ones are used, with some CSS wizardry to display the existing pending files nicely.
精彩评论