I have an image upload application in my drawing application that I wrote in Javascript. I want to allow the user to place several identical images on the canvas. However, when I try to load an image that is already on the canvas, nothing happens and the breakpoint in my event handler for the loader never hits. What is happening and how can I fix it? Thanks!
Here is the code for my image handler:
function handleImage(e) { var reader = new FileReader(); reader.onload = function(event) { var img = new Image(); img.onload = function() { img.className = 'drag'; img.style.left = 0; img.style.top = 0; context.drawImage(img, parseInt(img.style.left, 10) , parseInt(img.style.top, 10)); images.push(img); } img.src = event.target.result; } reader.readAsDataURL(e.target.files[0]); };
source share