so I have this input file and every time the file input change it sends the file data to a function
$('input#fileinput').change(function(e){
var tgt = e.target || window.event.srcElement,
files = tgt.files;
renderImage(files);
});
function renderImage(files){
return new Promise((resolve, reject) => {
var fr = new FileReader();
fr.onload = function(){
$('#image-editor-wrapper img').remove();
$('#image-editor-wrapper').append('<img id="img-raw" src="'+fr.result+'" style="position:absolute;visibility:hidden;z-index:99999"><canvas id="canvas-raw"></div>');
$('#crop-border').css('visibility','visible');
var c = document.getElementById("canvas-raw");
var ctx = c.getContext("2d");
var img = document.getElementById("img-raw");
document.querySelector('#canvas-raw').setAttribute('width',img.naturalWidth);
document.querySelector('#canvas-raw').setAttribute('height',img.naturalHeight);
ctx.drawImage(img, 10, 10);
}
fr.readAsDataURL(files[0]);
});
}
but its not working, like no image shown at all. Any help, ideas please?