boo_lolly Posted November 13, 2008 Share Posted November 13, 2008 Is the blob method used often? What purpose does it have exactly to store an image file in a database as opposed to storing the file in a folder somewhere on the server? my main question is HOW do you upload an image and store it in a database? Quote Link to comment Share on other sites More sharing options...
Gighalen Posted November 13, 2008 Share Posted November 13, 2008 You have to upload the image to a temporary directory on the server, convert that file to base64 and then save that into mysql as blob. This link should help you: http://www.weberdev.com/ViewArticle/Saving-Images-in-MySQL Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 13, 2008 Share Posted November 13, 2008 If you are using MySQL, it's really not worth it (in my experience). The one advantage is that your file is in your db record, so they will never be out of sync. But, every time you want to access the image, you have to do a DB query. So if you plan on accessing them a lot, you will probably end up writing something to cache them as files, so what's the point. MySQLi makes the inserts a LOT easier as you can use bind() to attach to a file handle. Then it sends the data in pieces, saving lots of resources. So, if you DO want to keep it in a blob, i would HIGHLY recommend using MySQLi Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted November 14, 2008 Author Share Posted November 14, 2008 thank you for the input. blobs seem a bit outdated. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 i wouldn't say outdated...just under-utilized. there is definitely a use for them... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.