Downloading PDF - can't open it

bunor90

New Member
I let my users download a PDF-file using this code:The \[code\]$db->Record['file']\[/code\] contains the relative path to the document.The access a dummy page that loads the pdf, so they do not actually see the "text.pdf" in the url. I changed the headers of the file to achieve this:\[code\]$downloadfile = '/data/srv/www/vhosts/htdocs'.$db->Record['file'];$filename = basename($downloadfile); header('Content-Type: application/pdf');header('Content-Disposition: attachment; filename="'.$filename.'"'); readfile($downloadfile);\[/code\]The download works without any problems, but when I try to open it, the following error ocurrs:\[code\]The PDF file could not be openend, the type is not supported or the filewas damaged.\[/code\]How can I fix this?Not: When I download the file directly, meaning to access is via \[code\]http://.../text.pdf\[/code\] and open it, everything works fine.
 
Back
Top