I need to write a function to return an image that
has been base64 encoded into a string.
This is how it is done in PHP and I need to know
how I can do the same in javascript:
function img_65()
{
header("Content-type: image/png");
header("Content-length: 174");
echo base64_decode(
"iVBORw0KGgoAAA ANSUhEUgAAABAAA AAWCAMAAAD+dOxO AAAAB3".
"RJTUUH0gkQEysK Ru4rNAAAAAlwSFl zAAALEgAACxIB0t 1+/AAA".
"AARnQU1BAACxjw v8YQUAAAAJUExUR QAAAP//AAAzM+Z4gaYAAA" .
"AoSURBVHjaY2DA AExMDIyMUARkYxH AABAJCAKysQgMnB ZkhEVg".
"QBwGAJlmANH7wb aHAAAAAElFTkSuQ mCC".
"");
}
Here is how I call it in my PHP code:
<?
$img = $_GET["img"];
switch($img)
{
case "65":
img_65();
break;
}
?>
In my HTML, I do this:
<img src="digits.php ?img=65" />
I have javascript base64 decode functions so I just
need to know how to change the content-type like
in img_65 function above above in javascript.
Also, how would I call this javascript function
in the img tag?
has been base64 encoded into a string.
This is how it is done in PHP and I need to know
how I can do the same in javascript:
function img_65()
{
header("Content-type: image/png");
header("Content-length: 174");
echo base64_decode(
"iVBORw0KGgoAAA ANSUhEUgAAABAAA AAWCAMAAAD+dOxO AAAAB3".
"RJTUUH0gkQEysK Ru4rNAAAAAlwSFl zAAALEgAACxIB0t 1+/AAA".
"AARnQU1BAACxjw v8YQUAAAAJUExUR QAAAP//AAAzM+Z4gaYAAA" .
"AoSURBVHjaY2DA AExMDIyMUARkYxH AABAJCAKysQgMnB ZkhEVg".
"QBwGAJlmANH7wb aHAAAAAElFTkSuQ mCC".
"");
}
Here is how I call it in my PHP code:
<?
$img = $_GET["img"];
switch($img)
{
case "65":
img_65();
break;
}
?>
In my HTML, I do this:
<img src="digits.php ?img=65" />
I have javascript base64 decode functions so I just
need to know how to change the content-type like
in img_65 function above above in javascript.
Also, how would I call this javascript function
in the img tag?
Comment