I have a function that uploads and image and adds a preview to this image, and i have two buttons, when i click on the first one it clicks on the input type file and opens it, a
Duplication the element and the script together will be helpful
check this i got it working as you want (took me a good time)
var i = 0;
$('#inputfile' + i).change(function() {
console.log(i);
if (this.files && this.files[0]) {
var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
}
});
function imageIsLoaded(e) {
console.log(i);
$('#ImgUpload' + i).attr('src', e.target.result);
};
function upload(id) {
$('#' + id).click();
};
$('#duplicate').click(function() {
i++;
var newelement =
'
' +
'' +
'' +
'
' +
'
' +
'