renstanford
asked on
How to show picture using "base64_decode()"?
I am using "base64_encode()" to store picture in a variable "$image".
I try to show this picture using "base64_decode($image)" but it failed, i don't know why?
anyone know what should i try/use?
I try to show this picture using "base64_decode($image)" but it failed, i don't know why?
anyone know what should i try/use?
ASKER
I encode a picture uploaded by user & save to mysql database (text field).
This is the code I used to decode from my database:
~~~~~~~~~~~~~
$result = mysql_query("SELECT userimage FROM photos WHERE id=1");
$image= base64_decode(mysql_result ($result,0 ,"pic"));
header("Content-type: image/jpeg");
echo "Picture:<br /><img src='$image>";
~~~~~~~~~~~~~
It doesn't show my image... how should I?
This is the code I used to decode from my database:
~~~~~~~~~~~~~
$result = mysql_query("SELECT userimage FROM photos WHERE id=1");
$image= base64_decode(mysql_result
header("Content-type: image/jpeg");
echo "Picture:<br /><img src='$image>";
~~~~~~~~~~~~~
It doesn't show my image... how should I?
ASKER
**Sorry.. this is the correction**
I encode a picture uploaded by user & save to mysql database (text field).
This is the code I used to decode from my database:
~~~~~~~~~~~~~
$result = mysql_query("SELECT userimage FROM photos WHERE id=1");
$image= base64_decode(mysql_result ($result,0 ,"userimag e"));
header("Content-type: image/jpeg");
echo "Picture:<br /><img src='$image>";
~~~~~~~~~~~~~
It doesn't show my image... how should I?
I encode a picture uploaded by user & save to mysql database (text field).
This is the code I used to decode from my database:
~~~~~~~~~~~~~
$result = mysql_query("SELECT userimage FROM photos WHERE id=1");
$image= base64_decode(mysql_result
header("Content-type: image/jpeg");
echo "Picture:<br /><img src='$image>";
~~~~~~~~~~~~~
It doesn't show my image... how should I?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the first comment in image.php - means do what you were doing before (obviously you still need to contact the database)
http://www.phpriot.com/d/articles/database/images-in-mysql/page8.html
is a pretty good tutorial that describes how to deal with images in php.
http://www.phpriot.com/d/articles/database/images-in-mysql/page8.html
is a pretty good tutorial that describes how to deal with images in php.
You need to do this in conjunction with displaying the header - in a php script by itself. called for each image you wish to retreive.