Uploading and displaying image from database

I am trying to display and image from a special get.php file. The whole purpose of this file is to display the image as though the enitre file was an image itself. It would be thought of as a changing immage depending on how you call the file. So if i called get.php?id=1. I would get the first image in the database. For the purposes of this example assume sercurity is not a consern for me. Here is the code.

[php]

<?php mysql_connect("localhost","champion_0369","hotmail0369") or die(mysql_error()); mysql_select_db("champion_vehicles") or die(mysql_error()); $id = addslashes($_REQUEST['id']); $image = mysql_query("SELECT `id`, `file_name`, `image` FROM `images` WHERE id=$id"); $image = mysql_fetch_assoc($image); $image = $image['image']; //$imagetype = 'jpeg'; header('Content-type: image/jpeg'); echo $image; ?>

[/php]

field image at database are blob? or string with path of file?

case BLOB:
I can’t check this, but if don’t works fine, try to put header(‘Content-type: image/png’). The syntax are correct.

case STRING:
remove “echo $image” and write
[php] $fres = fopen($image);
while(!eof($fres)){
echo fread($fres,1024);
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service