Possible Duplicate:
Retrieving file names out of a multi-file upload control with javascript
Got this:
<input type="file" name="file1" multiple="multiple" />
Using this in jQuery:
$("input[name=file1]").change(function() {
$("input[name=file]").val($("input[name=file1]").val());
});
Now my problem is this: It only gives the first selected file, I would like to have them all... How to do this? Thanks!
You are looking for the 'files' property, which returns a filelist:
Here is the Fiddle for it
Use
.length()
to get the number of files then use a while statement to do the same for all files, increasing the count by 1 each time :)Although I linked to a possible dupe in the comments, it's a pure JavaScript solution. Here's a jQuery version if you like: jsFiddle example