|
PDF Blob Error
Hello,
I have been able to upload a pdf and store it in the mysql database table. In phpMyAdmin I can verify that the pdf is the correct size. However when I try to download the file the document comes back blank and I get an error saying that acrobat could not open the file 'filename.pdf' because it is either not a supported file type or because the file has been damaged. The download code:
<?php
if(isset($_GET['nid'])){
$nid = mysql_real_escape_string($_GET['nid']);
$sql = "SELECT name,type,size,article FROM newsarticles WHERE newsid='$nid' AND active=0";
$result = mysql_query($sql);
$data = mysql_result($result, 0, "article");
$name = mysql_result($result, 0, "name");
$size = mysql_result($result, 0, "size");
$type = mysql_result($result, 0, "type");
//die ("The name is $name, the size is $size and the type is $type.");
header("Content-type: $type");
header("Content-length: $size");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
echo $data;
}?>
The query is working correctly because the die line has the correct information for the article.
Why am I unable to correctly download the pdf which has been stored as a blob?
Thanks in advance,
- Scott
|