Reading an image from a database.. |
[eluser]BrianDHall[/eluser]
http://us.php.net/function.getimagesize will give you the supposed mime type of the file before you store it in the database, so you'll probably want to save that. Check to make sure your mime is correct, because so long as the file info is stored correctly it should work. Though I was noticing you did use fread, fopen, and addslashes - the addslashes makes me wonder if you aren't corrupting the image data, but I don't usually do it that way so I don't know. Here's how I do it after using the upload class to upload a file: Code: $this->load->helper('file'); Then I just add the image data to the database basically with ActiveRecord and let it handle any escaping that may be needed. I use ORM (DMZ) so my code is actually: Code: $this->load->helper('file'); But the logic remains the same. I then save the mime type of the image along with the image data, then do a simple: Code: header("Content-type: " . $details->mime); I can tell you I was running into problems with transparent PNGs...so I just exluded that because I didn't care enough to look into why ![]() |
Messages In This Thread |
Reading an image from a database.. - by El Forum - 09-23-2009, 10:11 PM
Reading an image from a database.. - by El Forum - 09-23-2009, 10:35 PM
Reading an image from a database.. - by El Forum - 09-24-2009, 12:01 AM
|