我有一个具有文件输入元素的表单,当用户选择文件时,我想将所选文件设置为隐藏 iframe 中的另一个文件输入,
这是我的形式:
<form name="uploadForm" >
<input type="file" id="fileone" name="fileone" value="" />
<button type="button" id="attachement_upload" onclick="addFile()" >Upload</button>
</form>
<iframe id="FileUploadFrame" name="FileUploadFrame" src="" style="display: none; border: 0; width: 0; height: 0;">
<form id="FileUploadForm" name="FileUploadForm" accept-charset="utf-8" target="FileUploadFrame" enctype="multipart/form-data" encoding="multipart/form-data" method="POST" action="CIMtrek_Regional_WhseForm_FileUpload">
<input type="file" id="filetwo" name="filetwo" value="" />
</form>
</iframe>
和我的java脚本:
function addFile(){
//this is where i want to clone the fileone to filetwo and submit the form which is in iframe
}
我见过这样的事情,但真的不知道该怎么做:
$(".inputfield1").change(function(){
var $this = $(this), $clone = $this.clone();
$this.after(clone).appendTo(hiddenform);
});
请帮我完成这件事。