Creating Image from base64

images php coding issues or problems here.

Moderators: macek, egami, gesf

Jhays
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Oct 25, 2011 6:25 pm

Creating Image from base64

Postby Jhays » Thu Mar 01, 2012 12:36 pm

Hey Guys,

What I'm trying to do is capture a signature from canvas and save it either as a jpg or a png. I've been able to capture the images source with javascript and send it over to the next php page to be processed. Once the image has been processed I'd like to save the image in a folder.

Here's my problem I have an image source passed from a canvas drawing from another page and I can send it over anyway "image/jpg","image/png". My question is when it is sent over its already set over in base64. How can I get that base64 to create and image from that?

I've tried using this line of code to save the image right away
file_put_contents('signature.jpg', base64_decode($_POST['i1']));

and just passing it like this as well
file_put_contents('signature.jpg', $_POST['i1']);

But when I go to view the image I get these error messages in Photoshop "Could not complete your request because a JPEG maker segment length is to short".

Thanks.

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 3 guests

cron