Hello,
I am having a hell of a time downloading an image that I've stored as type 'blob' in a mysql database. Anyone who can offer help would be most appreciated as I'm about to give up.
Basically, with the code listed below, when I click the download link, I get a 'save as' window (which is what I want). I'm then able to save the file to my desktop and it appears as a jpeg file. I can even open the file correctly in Photoshop (from the desktop). However, the problem is I can't view the file in I.E. or any other browser (by opening it from the desktop or double-clicking it). I absolutely need the user to be able to view the file in the windows 'preview pane' or browser once it's been downloaded.
Here is my basic code:
$sql = "SELECT image, image_type, image_name, image_size FROM Designs WHERE design_id=$design_id";
$result = @($sql, $connect_ID);
$data = @mysql_result($result, 0, "image");
$name = @mysql_result($result, 0, "image_name");
$size = @mysql_result($result, 0, "image_size");
$type = @mysql_result($result, 0, "image_type");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: $type");
header("Content-Disposition: attachment; filename=$name");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $size");
echo $data;
For verification, I've printed out the $name, $size, and $type variables and they read as follows: box_bottom.jpg, 2256, image/pjpeg.
$data is the actual blob info.
Thanks alot!!!!