PDF Download from BLOB help.
Posted: Thu Sep 04, 2008 11:09 am
Hello,
I'm having a few problems downloading an uploaded PDF file from the BLOB field. Everytime each PDF opens up in Acrobat, it gives me an error saying that the file is corrupted.
This is what I do to the file before database insertion
and here's the code that I am using for download.
any help?
I'm having a few problems downloading an uploaded PDF file from the BLOB field. Everytime each PDF opens up in Acrobat, it gives me an error saying that the file is corrupted.
This is what I do to the file before database insertion
Code: Select all
<?php
$tmpName = $_FILES['form_upload']['tmp_name'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
?>Code: Select all
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/ext/classes/class.forms.php');
$forms = new forms;
$file = $forms->downloadForm($_GET['file_id']);
header("Content-type: ".$file->fields('form_type'));
header("Content-Disposition: attachment; filename=".$_GET['file_name']);
echo $file->fields('file_data');
?>