Jump to content

storing images in the db


skaterdav85

Recommended Posts

I'm getting an error when converting a list of images in my directory to blob types. The problem occurs when it tries to convert the GIF images to the base64 type. How can i store any kind of image in my db?Error:An error occured in converting the image to base64 in the required image encoding. Base64 images can be created with ColdFusion in BMP,JPEG,PNG,PNM,and TIFF formats.

Link to comment
Share on other sites

An error occured in converting the image to base64 in the required image encoding. Base64 images can be created with ColdFusion in BMP,JPEG,PNG,PNM,and TIFF formats.
Based on the error message, it looks like CF doesn't have the ability to convert GIFs, just BMP,JPEG,PNG,PNM,and TIFFs. You could convert the GIFs to one of those formats and then store them, I suppose. FWIW, I rarely store images in a DB unless security is important, as it's a very inefficient way to do things. There's a lot of overhead in retrieving the image and converting it back to its usable form. It's often better (more efficient/faster) to store just a pointer containing a file path to the image in the DB. If direct access to the images isn't supposed to be allowed, you can always store the images above the root and have a bit of code stream the image to the browser.
Link to comment
Share on other sites

i've heard the benefits /drawbacks of doing it both ways. I was more curious about storing the images themselves in the db so I thought I'd try that out this time. Someone suggested I use the FileReadBinary() function in CF to read the byes out of the GIF image and then convert them to the base64 type with ToBase64(), so I'll try that. If no luck, I guess I'll just go back to storing the image filenames in the db.

Link to comment
Share on other sites

I'm curious...other than increased security, I'm wondering what the other benefits or advantages would be to storing the images in the DB.

i've heard the benefits /drawbacks of doing it both ways. I was more curious about storing the images themselves in the db so I thought I'd try that out this time. Someone suggested I use the FileReadBinary() function in CF to read the byes out of the GIF image and then convert them to the base64 type with ToBase64(), so I'll try that. If no luck, I guess I'll just go back to storing the image filenames in the db.
Link to comment
Share on other sites

  • 3 weeks later...

If this is still an issue - first make sure BLOB field types are enabled in the ColdFusion Administratior. It is in the settings section.As far as using blobs, there are many advantages. Security, portability, and version control come to mind. The benefits become greater when you consider clustered servers and load balancing.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...