views:

63

answers:

3

I created an .png image from a video using ffmpeg tool and i want to how to insert that image into the db which has a blob field and also i want to know how can i recollect that image from the db to display as a image again?

+1  A: 

In general it is not recommende to store images in the db. It is usually better to store them in the fs and only keep the meta data in the db.

Rickard von Essen
I've using this technique because i've huge no of images and its easier for me to retrieve the images based on the requirement instead of getting the desired records first and then again going for the images using metadata.
kvijayhari
I disagree. Obviously there are drawbacks, but if you implement it correctly these are mitigated. You should use a link table if you are going to use a database to store BLOBs and only store a foreign key to those BLOBs in other tables. Many business apps use databases for file storage and take advantage of the pros.
JD
@JD The standard argument against putting images in the db is that the fs i better at handling binary content (images). But yes, this can be debated.
Rickard von Essen
+1  A: 

use file_get_contents($fileDir); and then insert into a text column type in your database ensuring that you base64_encode your file_get_contents string before inserting.

It's called BLOB inserting.

JD
http://www.java-samples.com/showtutorial.php?tutorialid=930 is an example
JD
+2  A: 

It's generally a better idea to only store the filename or path to the image in the database rather than storing it as a blob. You'll notice a big performance hit when you have a large volume of images.

Aside from that, it's a lot easier and more secure to use php's built-in file and image functions on actual files, rather than having to process the blob beforehand.

Lotus Notes