sophielois
Technical User
Hi all,
Im getting the following error when trying to open a pdf file using the follwong code
ERROR
!Acrobat could not open HSC21[1].pdf because it is not a supported file type or the file has been corrupted for example it was sent as an email attachment and wasn't correctly decoded
Can you see where im going wrong?
Soph
Im getting the following error when trying to open a pdf file using the follwong code
ERROR
!Acrobat could not open HSC21[1].pdf because it is not a supported file type or the file has been corrupted for example it was sent as an email attachment and wasn't correctly decoded
Code:
<?php
function downloadFile($thefile, $ctype, $dname) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: ".$ctype);
header("Content-Length: ".filesize($thefile));
header("Content-Disposition: attachment; filename=\"".$dname."\"");
header("Content-Transfer-Encoding: binary");
$fp = fopen($thefile);
$txc = fpassthru($fp);
fclose($fp);
}
$thefile = "HSC21.pdf";
$ctype = "application/pdf";
$dname = "HSC21.pdf";
downloadFile($thefile, $ctype, $dname);
?>
Can you see where im going wrong?
Soph