NogDog - I should have mentioned that SQLQuery is my own function to handle my db connection, etc and that I'm using MySQL as a db.
I've made a little progress in that I'm now storing data in the blob field. I must have been doing something dumb before (was I even refreshing the screen with Windows explorer after I wrote records to see if the db size changed??) as I really haven't changed my code.
My only indication that it's now working is the db is growing by the epected amount. Though it doesn't make any difference from that persepctive, I also changed from addslashes() to mysql_real_escape_string (thanks Brad).
I've created a couple of records, one holding a .jpg and one with a .pdf. Unfortunately, I can't get either to display. I'm not sure if it's because I'm pumping garbage in or if I'm missing something on the output side.
My insert code is:
<?
if ($REQUEST_METHOD == "POST") {
$file_name="/1090/WD-D.pdf";
$instr = fopen($file_name,"rb");
$file_content = mysql_real_escape_string(fread($instr,filesize($file_name)));
fclose($file_name);
SQLQuery("mydb", $cid, "insert into blob (file_name, blob_file) VALUES('$file_name', $file_content')");
}
?>
For the display side of the pdf I'm trying:
<?
$blob = SQLQuery($dbname, $cid, "select id, blob_file from blob where id = 1");
header("Content-type: application/pdf");
print(mysql_result($blob, 0, "blob_file"));
?>
and for the image I have this in a .php page:
<img src = "show_blob.php">
and this for show_blob.php:
<?
$blob = SQLQuery($dbname, $cid, "select id, blob_file where id = 2");
header("Content-type: image/jpeg");
print(mysql_result($blob, 0, "blob_file"));
?>
When I try to display the .pdf, nothing happens. And when I try to display the image, I get a red "x" where it's supposed to be.
Any other help is appreciated.
Thanks!