Hi
i need help that how to store the images in the mysql table and retrieval of stored image using php code...
sample code that helps me a lot..
regards ~Deepu~
Hi
i need help that how to store the images in the mysql table and retrieval of stored image using php code...
sample code that helps me a lot..
regards ~Deepu~
Create a table in database with Blob field and another varchar field for picture type (jpeg/gif/etc..), store the picture in there.
To store the picture do the following:
fread
of file_get_contents
To retrieve picture back do regular select statement to get the picture data and file type.
Set the header Content-type
to appropriate file type and display the picture data.
For example:
HTML
<img src="getPicture.php?id=12345" />
PHP
<?php
$id = (int) $_GET['id'];
// Assume $db is out DAL that is already connected and can query database
$img = $db->loadObject("SELECT pic_data, pic_type FROM picture WHERE id = $id LIMIT 1");
// We get the following
// $img->pic_type = 'image/jpeg'
// $img->pic_data = 'picture data'
//
//
// Make sure there is not output prior setting header
header("Content-type: $img->pic_type");
echo $img->pic_data;
Look at this page. There is code it will help you http://www.anyexample.com/programming/php/php_mysql_example__image_gallery_(blob_storage).xml