Hey - I'm playing around with storing image files as binary data in my MySQL database, and pulling them down using the following code:
PHP Code:
if($id) {
$conn = mysql_connect('sqladdress', 'username', 'password') or die ("Problem connecting to the database" . mysql_error() );
$rs = mysql_select_db("databasename", $conn);
$query = "select imagebinary,filetype from show_info where id=$id";
$result = mysql_query($query);
$data = mysql_result($result,0,"imagebinary");
$type = mysql_result($result,0,"filetype");
Header( "Content-type: $type");
echo $data;
};
which is saved as filetype.php, and accessed with:
Code:
<img src="filetype.php?id=1">
This works fine, but I'm setting this up for some endusers who don't know a gif from a jpg from a hole in the ground -- is there a way to use PHP to detect the file time for the header information directly from the binary code? Anybody heard of such a thing?