## Heres where I add images to DB with field type of BLOB for image
if ( ($submit == 'Add Image') && ($userid != 'demo') ){
if ($image != 'none'){
$name = strtr($name, "'", " ");
$image = addslashes(fread(fopen($image, "r"), filesize($image)));
mysql_select_db($dbase) or die( "Unable to select database");
$query = "insert into images values ('$name','$image')";
mysql_query($query);
if (mysql_error()){
echo ("<BR><BR><BR><center> Upload of image failed. It is possible
the");
echo (" image name is already on file. Try another name.</CENTER>");
echo ("</BODY></HTML>");
exit;
}
}
$submit = 'Image Index';
}
Here's my image script. I know I should send more information in the Header, but
it works w/out it. Notice that I ommitted the stripslashes. I ran into the same
problem as you are having when I had the stripslashes in it. I would make more
sense to me if you had to use the stripslashes.
<?
include("connect.php4");
mysql_select_db($dbase) or die("Unable to select DB ".$report_to);
$query = "select image from images ";
$query .= "where (image_name = '$name') ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
extract($row);
Header( "Content-type: image");
echo $image;
?>
Your code.
===================================
$query = "SELECT filename, filedata, dateline FROM reviews where id=$id";
$results = dbQuery($query);
$filedata = stripslashes($results["rowData"]["FILEDATA"][0]);
$filename = $results["rowData"]["FILENAME"][0];
if (strstr($HTTP_USER_AGENT,"MSIE")) {
$attachment = '';
} else {
$attachment = ' atachment;';
}
header("Cache-control: max-age=31536000");
header("Expires: " . gmdate("D, d M Y H:i:s",time()+31536000) . "GMT");
header("Last-Modified: " . gmdate("D, d M Y
H:i:s",$results["rowData"]["DATELINE"][0]) . "GMT");
header("Content-disposition:$attachment filename=$filename");
header("Content-Length: ".strlen($filedata));
$extension=strtolower(substr(strrchr($filename,"."),1));
if ($extension=="gif") {
header("Content-type: image/gif");
} elseif ($extension=="jpg" or $extension=="jpeg") {
header("Content-type: image/pjpeg");
} elseif ($extension=="png") {
header("Content-type: image/png");
} elseif ($extension=="pdf") {
header("Content-type: application/pdf");
} else {
header("Content-type: unknown/unknown");
}
echo $filedata;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php