Hi,
I am querying a webservice which returns images as Base64 encoded data.
Displaying these images in Firefox is not a problem:
<img src="data:image/jpeg;base64,<%=@image_data%>">
However, I am having trouble displaying the images in Internet Explorer.
I have been looking at the following page:
http://dean.edwards.name/weblog/2005/06/base64-ie/
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:
<img src="<%=@image_data_decoded%>">
----
@image_data_decoded is a binary string that does work correctly when
passed to the view.
What i am doing wrong?
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---