Jump to content

Using base64_decode to display a GIF image from an Array


mmc215

Recommended Posts

Hey folks, I am using a PHP product to produce shipping labels directly from a major carrier. The php script returns an array of info with the image data sent in Base64 format.

 

I'm told that I can display this as an image (GIF) in the broswer with this format but I'm pretty much lost (don't laugh, I'm only an html/css simpleton):

 

<img src="data:image/gif;base64,iVBORw0KGgoAAAANS..." />

 

Here's the resulting data I need to turn into a printable GIF image:

 

Array
(
  [charges] => 6.89
  [trk_main] => 1Z5977460394839629
  [pkgs] => Array
    (
      [0] => Array
        (
        [pkg_trk_num] => 1Z5977460394839629
        [label_fmt] => ZPL
        [label_img] => Cl5YQV5MUk5eTU5ZXk1GTixOXkxIMTUsMTBPSV5QVzg...

 

 

Any help would be so awesomely appreciated!

mmc

 

 

Not tested, but maybe something like this:

 

display.php

<?php
header('Content-Type: image/gif'); 
echo base64_decode($array['pkgs'][0]['label_img']);
?>

 

Then wherever you want to display it:

<img src="display.php" />

Would need to see more code or have an explanation of how you retrieve this data.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.