[英]How to keep existing file selections on multiple selections
In html we can select multiple files at once using file input control. 在html中,我们可以使用文件输入控件一次选择多个文件。 But when i selected a file second time previous files overwritten by the newly selected files.
但是当我第二次选择文件时,先前的文件被新选择的文件覆盖。
My question is, Can we able to keep existing file selections while selecting new files? 我的问题是,在选择新文件时我们能否保留现有文件选择?
I didn't get any snippet related to this, seems most people doesn't require this kind of functionality. 我没有与此相关的任何片段,似乎大多数人都不需要这种功能。 So i did it myself.
所以我自己做了。
clone
method. clone
方法clone
具有重复ID的当前文件输入 。 This cloned input control set to hidden and current input control holds latest files. I doubt how well this method works in older browsers, but current chrome and firefox executes it well. 我怀疑这种方法在较旧的浏览器中的效果如何,但是当前的chrome和firefox能否很好地执行它。
I think your problem is that you give the same name to the different <input> tags.
<div id="selectFiles">
<input type='file' name='userFile1'>
<input type='file' name='userFile2'>
<input type='file' name='userFile3'>
<input type='file' name='userFile4'>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.