I am using "multiple" tag to let user choose multiple files for uploading.
<input type="file" name="files[]" multiple />
But it only shows e.g., "3 files selected". It would be better to also show file names.
Is it doable? Thanks.
BTW, in this case how to deselect files (e.g., clear the list)?
You can do this with the
.files
property on the input element:This first empties the list in case there's still something from the previous selection, and then it goes through each item in the file list, and then adds that to the
<pre>
element underneath the input. The<pre>
will be hidden if there are no selected items in the list.PS: you can clear the list by just clicking the input, and then either pressing esc or clicking "cancel" on the file-selection window.