View Full Version : Submitting An Image To A Database
dreamerp
April 16th, 2005, 07:36 PM
Hello,
I was wondering if anyone knew the best possible way to submit images to a database to be stored with information about the image, and the image itself rather than storing it in a folder.
Thanks,
Peter
Lukus
April 16th, 2005, 08:41 PM
Ya can't store images in a db :)
Only thing you can do is store the location of the image (whether its from a different site, or use a script to upload the image to your site and store that location) :)
MTsoul
April 16th, 2005, 11:14 PM
Yes you can store images in a database (MySQL)
Create a table, and for the property for one column, select BLOB. Select medium/tiny/large blobs according to the file size that you estimate will be. NOrmally, for an image, BLOB is fine.
BLOB is the format to store files as binary. Simply store the file data (the actual image) and the file format (.jpg, .gif etc). When you want to display the picture, use the header() information to select display type for the http request. I remember there's a tut on kirupa.com about it. Search for it. And then simply echo the data that's stored in the BLOB column.
sinus_
April 17th, 2005, 12:35 AM
omg nice. thanks. i planning to try this out in the near future... :D
Lukus
April 17th, 2005, 01:53 PM
Wow, I really didn't know that :P Cool
Must eat up space tho?
MTsoul
April 17th, 2005, 02:40 PM
Not at all. In fact, it takes less space than if you want to automatically store it in a directory. With PHP, you'd have to make a temp file, then move it (and use up memory and temp file space), and then delete the temp file. This takes longer time and bigger memory for the server.
For MySQL, however, all you'd have to do is insert it. Ta-da. No worries. But one thing though, your file is stored in MySQL. MySQL crashes more often than the server does, which means you'd have to frequently back up your data.
hl
April 17th, 2005, 10:34 PM
base64 works too
heres a nice tutorial i found http://www.spoono.com/php/tutorials/tutorial.php?id=42
teiz77
April 18th, 2005, 08:13 AM
read this thread... i posted a full solution
http://www.kirupa.com/forum/showthread.php?t=88979
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.