Hi,
I am querying a webservice which returns images as Base64 encoded data.
Displaying these images in Firefox is not a problem:
However, I am having trouble displaying the images in Internet Explorer.
I have been looking at the following page:
Dean Edwards: Base64 Encoded Images for Internet Explorer
which uses a regular expression in Javascript to identify any Base64
images and then uses a PHP function to decode the data and display it
correctly Internet Explorer.
I have been trying to do the decoding of the data in the controller
(rather than having to use the Javascript & PHP method) but I can’t get
it to work:
Controller:
require ‘base64’
@image_data =
“R0lGODlhDwAPAKECAAAAzMzM/////wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4MLwWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw==”
This is Base64 encoded
@image_data_decoded = decode64(@image_data)
View:
@image_data_decoded is a binary string that does work correctly when
passed to the view.
What i am doing wrong?
Thanks