我有4个input [type =“ file”],允许用户上传4张图像。现在如何在上传之前预览每个输入[type =“ file”]中所有选择的图像?
我尝试了下面的代码。但是它将在每个输入[type =“ file”]
中显示相同的图像 function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$("#vehicle-pickup-img-tag1,#vehicle-pickup-img-tag2,#vehicle-pickup-img-tag3,#vehicle-pickup-img-tag4").attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#vehicle-pickup-img1,#vehicle-pickup-img2,#vehicle-pickup-img3,#vehicle-pickup-img4").change(function(){
readURL(this);
});