I have a form which allows the user to upload a picture. After the user has submitted the form, I\'d like to generate on the front-end a thumbnail for each picture and then
After a better search online I found the answer to my question.
It is possible to combine canvas together with the File API.
Try to upload any picture in the demo below and see that a new generated thumbnail will appear on the right side of the form.
DEMO: http://jsfiddle.net/a_incarnati/fua75hpv/
function handleImage(e){
var reader = new FileReader();
reader.onload = function(event){
var img = new Image();
img.onload = function(){
canvas.width = img.width;
canvas.height = img.height;
ctx.drawImage(img,0,0);
}
img.src = event.target.result;
}
reader.readAsDataURL(e.target.files[0]);
}
A good answer has been given by DerekR to this question:
How to upload image into HTML5 canvas