Dear members, can any body plz help me out to insert image file in MySQL.......is it possible ????????

If possible plz give me the code............

By general, I insert only the name of an image. I save the images in a folder.

Anyway, sure that you can do so. There are some tutorials talking about that. You will have to do output buffering to display the mime content stored in the mysql record with header function or ob_start (depending if the headers are already sent).

Look at the ONLamp tutorial.

First, very important, to upload the image you will need enctype="multipart/form-data" inside the html form tag to set the suitable encode type to send files.

Then you use fread to get the file content in a variable (use fopen before with the given url parameter), then we can insert the mime type and the content.

To get the data, you can do this like another data type, but taking care regarding to when you output the MIME header.

If you are inserting images in the middle of the document, for example (not covered in the tutorial), you will need something like this snippet:

function output_handler($image) {
   header('Content-type: '. $data["mimeType"]);
   header('Content-Length: ' . strlen($data["fileContents"]));
   return $image;
}

ob_start('output_handler');
echo $data["fileContents"];
ob_end_clean();

Dear members, can any body plz help me out to insert image file in MySQL.......is it possible ????????

Dude , have you read at least one php book ????

Inserting images in MySql it's possible by using a BLOB column , but is very very inefficient
It takes a lot of space , thus slowing down the queries ( like search,select )

Usually when it comes to images in mysql , you only store the name or the pathname of the picture

This article has been dead for over six months. Start a new discussion instead.