Vote count:
0
Im making a file uploader and I need to get the ID for each image selected in order to delete them later, any idea?
Im trying to use "imgn" but it's not working.
var imgn=0;
function readURL(file) {
var reader = new FileReader();
var image = new Image();
reader.readAsDataURL(file);
imgn++;
reader.onload = function (e) {
image.src = e.target.result;
image.onload = function() {
$('#imgpre').append('<p id="imgnum'+imgn+'"><img src="'+ this.src +'" width="80px"><input type="button" value="Remove" onclick="removeimg('+imgn+');"></p>');
}
image.onerror= function() {
alert('Invalid file type: '+ file.type);
}
}
}
$("#imgsel").change(function(e){
if(this.disabled) return alert('File upload not supported!');
var F = this.files;
if(F && F[0]) for(var i=0; i<F.length; i++) readURL( F[i] );
});
function removeimg(rnum) {
jQuery('#imgnum'+rnum).remove();
}
asked 38 secs ago
How to give an unique ID for each file selected when uploading multiple files
Aucun commentaire:
Enregistrer un commentaire