Hi,
I hope someone has run into this before. I have a new Web app I'm developing; it currently only runs on my machine, using XAMPP as the testing server. I created a folder outside of the web root, called '_pdfs' to house PDFs which will be uploaded by users; once the PDFs are approved, users will be able to see the titles presented on a PHP page in a table of hyperlinks, which can be clicked to obtain the file.
Following instructions found elsewhere, I included a function called 'send_download()', included here:
function send_download($filename)
{
$file_path = '../_pdfs/' . $filename;
$file_size=@filesize($file_path);
header("Content-Type: application/pdf");
header("Content-disposition: attachment; filename=$filename");
header("Content-Length: $file_size");
readfile($file_path);
exit;
}
Here's where it breaks: the table with the links displays properly, and apparently sends the user to the correct page, which calls the PDF. Adobe Reader then loads, and asks if the user wants to open or save the file (and the name it gives is correct). However, when it tries to open the PDF, it stops and instead displays this error message:
Adobe Reader could not open '12345_upload_test.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded.
I believe it's finding the file correctly, but wonder if there is a header problem or such.
Thank you for your assistance.