sillysillysilly Posted October 26, 2007 Share Posted October 26, 2007 I am trying to take the data from an xml file that is base64 encoded image and view it. I have a code snippet that will take the data and save it to a file. The file can be viewed as a jpg in a picture viewer but cannot be viewed in a web browser. I would rather have it do both, save to a file for tracking purposes and be displayable in a web browser because this will be sent to a third person to print out in their email. Here is the code I am using. $image_data = "SUkqAAgAAAASAP4ABAABAAAAAAAAAAABBAABAAAApAYAAAEBBAABAAAAmAgAAAIB AwABAAAAAQAAAAMBAwABAAAABAAAAAYBAwABAAAAAAAAAAoBAwABAAAAAgAAABEB (trunkated to be brief). $theFile = base64_decode($image_data); $file = fopen('test.jpg', 'wb'); fwrite($file, $theFile); fclose($file); echo '<img src=test.jpg>'; any ideas on what I need to do to make it viewable in the browser? Link to comment https://forums.phpfreaks.com/topic/74911-decoding-base64-into-an-image/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.