Creating an image file from base64 text

images php coding issues or problems here.

Moderators: macek, egami, gesf

iJim
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Dec 09, 2012 2:59 am

Creating an image file from base64 text

Postby iJim » Sun Dec 09, 2012 3:07 am

Hi to everybody,
[excuse me for my english!!!]
I have an image stored in database (MySQL), in base64 text format, when i write this code:

Code: Select all

$imgData = str_replace(" ","+",$imgText);
echo '<img src="'.$imgData.'">';

It work.

But i want create an image file..
I try this, but it doesn't work

Code: Select all

header(‘Content-type: image/png’);
echo base64_decode($imgData);

User avatar
kiash001
New php-forum User
New php-forum User
Posts: 16
Joined: Wed Feb 27, 2013 2:49 am
Location: Dhaka, Bangladesh
Contact:

Re: Creating an image file from base64 text

Postby kiash001 » Tue Mar 05, 2013 9:08 am

I think the problem is

Code: Select all

data:image/jpeg;base64,

Solution is

Code: Select all

base64_decode(str_replace("data:image/jpeg;base64,", '', $data));

iJim
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Dec 09, 2012 2:59 am

Re: Creating an image file from base64 text

Postby iJim » Tue Mar 05, 2013 9:33 am

Thank you


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 0 guests