Javascript & File Upload Fields - Manipulating File Input [duplicate]
Possible Duplicate:
Multiple file selectio开发者_运维百科n for an upload control
Is it possible for me to use a
<input name="userfile[]" type="file" title="Select Your Files" multiple=""/>
To have the users select more than 1 file at once.. But then Separate all the files into individual file inputs via javascript?
As an example, i click to choose files for my input, and select Image1.jpg, image2.jpg. and image3.jpg all while holding ctrl for the multi-selection.. Then once i click on a button, a function is triggered that'll split that input into multiple single file inputs for each file.
This is not possible for security reasons. As @Pointy stated (in a comment to the question) you can't do this because the browsers' security model will not let you manipulate the value of the field with JavaScript.
There are many solutions to this problem (e.g. SWFUpload) that allow you to use a flash control to allow the user to pick as many files as desired (they even let you filter on what filetypes (and/or sizes)) are permitted... yet they will auto-split the files into separate fields that can be uploaded as normal or asynchronously via AJAX.
精彩评论