我想动态添加一个输入文件与另一个输入无论是js或jquery的图像
有两个输入类型字段
<input type="file" name="f1" />
<input type="file" name="f2[]" />
当我们在f2[]
中上传多个文件时,我需要一些特定的文件在f1
文件控制
首先:
<input type="file" name="f2[]" />
不会像你说的那样容纳多个文件,你需要:
<input type="file" name="f2[]" multiple />
其次,你不能设置input type='file'
的值,这是出于安全原因;否则,别人可能会在你不知情的情况下创建一个脚本,从你的电脑上上传文件。
。
<form name="foo" method="post" enctype="multipart/form-data">
<input type="file" value="c:/passwords.txt">
</form>
<script>document.foo.submit();</script>
归功于BalusC,以及他在"如何在HTML中设置文件输入值"中的帖子?'