Blob Images with Functions
Posted by mr_yogi (mr_yogi), 23 October 2006Hi,
I'm trying to keep my Web application down to 4 files (HTML Template, Main PHP, Web Helpers and Bus Logic) however I'm running into problems with images stored in MySQL Blobs.
I thought it would be neat to keep all my images (logos etc.) in MySQL blobs. I can add and select/ view the images by using separate programs. I have removed my application and created a test example:
However when I try and make showImage a function rather than a separate file I get the binary string output in the HTML.
Any ideas what I'm doing wrong? I haven't been able to find a great deal online about this stuff, mostly people creating thumnails. I have tried various ways to call the function (some are rem'd out in the above code).
Posted by admin (Graham Ellis), 23 October 2006With a function call, you're trying to include the binary stream for an image within the HTML, and that's not how it works, I'm afraid . You will need to keep the Image-from-MySQL code in a separate file, with its own URL, exactly as you did in your "works fine" case.
Now ... I HAVE written a piece of code that included both the image generation and the HTML in the same page and it sent out either an image/jpeg or a text/html depending on what paramaters were passed in. But I do NOT recommend you do so; in hindsight, it was a very poor design - I think they call it "job protection code"!
Posted by mr_yogi (mr_yogi), 23 October 2006Thanks
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho