Can I add Images to a HTML upload form using javascript?

984 Views Asked by At

I want to extend the CMS gpeasy with a javascript that it resizes images before uploading them, to prevent the web server from running out of memory. I can resize an Image with an html5 canvas. With the .toDataURL(image/jpeg) method i can generate an image (that I could use in the src attribute of an ing tag). Does anyone know, how to add this to an upload form so that the CMS can continue it's AJAX upload process?

1

There are 1 best solutions below

1
On

Well the .toDataURL() gives you an base64 representation of the image, right? You can pass that string to your back-end and process the string into an image there. If you are using PHP you can easily do that using GD and the function imagecreatefromstring().