如何设置文件输入字段的值以与从其他文件输入中选择的文件链接?因此,当用户在input1中选择文件时,input2字段将自动填充第一个中选择的文件。我希望能够用jQuery做到这一点,但我无法让它工作:
示例:
<input type="file" name="input1" id="input1" onchange="previewImage1T1(this)" />
<input type="file" name="input2" id="input2">
她是我的尝试:
function previewImage1T1(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
//the only jQuery line. All else is the File API.
$('#image1T1').attr('src', e.target.result);
$('#input2').val = input.files[0];
}
reader.readAsDataURL(input.files[0]);
}
}
有人可以帮助它会非常感激,我确信它的东西非常简单,我忽略了