So I’ve started playing around with php and mysql and have managed to store pdf files in mysql db. Now I want to allow users to view the pdf’s and this is where I’m stuck. See code below: (Code from book by Kevin Yank)
----Code Start----
if (isset($_GET[‘action’]) and
($_GET[‘action’]==‘view’) and isset($_GET[‘id’])){
The mediumblob can hold over 16MB so unless your files are larger than that I’m guessing you either stored bad data, i.e. didn’t use readfile, or you need another header or more.
You may need cache header(s) (the file not found error?)
Thanks Mittineague,
I have tried to include the suggested headers, no luck. The blob was inserted into the db with the following code extract:
--------Code Start---------
$uploadfile = $_FILES[‘upload’][‘tmp_name’];
$uploadname = $_FILES[‘upload’][‘name’];
$uploadtype = $_FILES[‘upload’][‘type’];
$uploadsize = $_FILES[‘upload’][‘size’];
$uploaddesc = $_POST[‘desc’];
$f=fopen($uploadfile,“r”);
$uploaddata=fread($f,filesize($uploadfile));
$uploaddata = addslashes($uploaddata);
include ‘…/Dbcnx.php’;
mysql_query(“insert into docs(Title,DocData,DocType,DocName,DocSize) values (‘$uploaddesc’,‘$uploaddata’,‘$uploadtype’,‘$uploadname’,‘$uploadsize’)”);
------Code End--------
The blob is uploaded into the db as I can view the binary data from the MySQL Query Browser. Also in another part of my web app I can view the pdf by following the same method explained perviously. So, being a newbie, I thought I could transplant this “viewing” feature to the public section to allow users to view these pdfs.
All spaces in file names have been replaced with underscores(_) so I’m certain the filename is not the problem. I tried your suggestion anyway but no luck.
Please see previous post for code used to insert pdf into db.
Just managed to get IE 7 to work, it was a problem with ActiveX for adobe reader. I had to run repair to get it fixed. It is important to ensure that the follwing files are present for adobe reader: