How can I draw an image from the HTML5 File API on Canvas?
I would like to draw an image opened with the HTML5 File API on a canvas. In the handleFiles(e) method, I can access the File with e.target.files[0] but I can't draw that image directly using drawImage . How do I draw an image from the File API on HTML5 canvas? Here is the code I have used: <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script> window.onload = function() { var input = document.getElementById('input'); input.addEventListener('change', handleFiles); } function handleFiles(e) { var ctx = document.getElementById('canvas').getContext('2d'); ctx.drawImage(e.target.files[0],