Hello--
I can't quite seem to get this to work. What I'm trying to do is pull data
out of a MySQL db of an image that I had put into the db. When I originally
put the image into the db I had to use the "addslashes" function so that it
would be inserted into the db correctly. Now when I select the data out of
the db I do "stripslashes" on the file data. However, I still get a broken
image in my test page. So I included the code I'm using below. the only
ting that I can think of (it actually just popped into my head) is for a 50k
file how big would the table have to be? I'm currently using the field type
of mediumtext which should be enough.
Thanks for any help!
jay
===================================
$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