From: Carlos Date: 2005-01-06T08:24:48+09:00 Subject: Re: Image decompression, eruby [Belorion , 2005-01-06 00.01 CET] > I am working on a website with a MySQL backend. The site allows > users to upload files, such as jpg, gif, etc. I'm having issues > loading images from the database and getting them to display in the > webbrowser. > > Since the raw image encoding contains characters MySQL doesn't like > when doing an INSERT, I encoded the image using Base64.encode64(). > > So, when I pulled the data back out, I do a Base64.decode64(). > > I also do a: > > print cgi.header( "type=>image/jpg" ) so I have the correct header, Shouldn't that be cgi.header("type"=>"image/jpg") ? > and then I dump the data by simply using <%= data %> as the only > information that is sent to the browser other than print cgi.header. Just a guess: check for blanks/new lines around the <%= data %>. ... > What am I doing wrong? Does encoding/decoding in Base64 totally screw > this up? Any other recommended approaches? As I mentioned, Firefox is > aware of the fact it is image/jpg, but IE does not. In either case, > the raw data is not a properly encoded jpeg. The other possibility is to add a header "Content-Transfer-Encoding: base64" and send the base64 encoded photo directly. Good luck.