Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Creating an image file from base64 text

images php coding issues or problems here.

Moderators: macek, egami, gesf

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);
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 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));
User avatar
kiash001
New php-forum User
New php-forum User
 
Posts: 16
Joined: Wed Feb 27, 2013 2:49 am
Location: Dhaka, Bangladesh

Re: Creating an image file from base64 text

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

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


Return to PHP coding => Images

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.