I am trying to get a pdf file from the server using php. The file is pdf and it is not corrupt, but when I use this code adobe says its a corrupt file.
I just want to show a file to users like a regular link
<a href="123.pdf"> this file </a>
but i am using php because it is going to an htaccess locked directory so I am having php get it.
Is there any other way to do it?

<?php
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary ");
header("Content-Disposition: attachment; filename=123.pdf");
readfile("/home/xx/public_html/downloads-locked/");

?>

In line 5 you are specifying a directory, I think you'll have to put the filename in that parameter along with it's relative or absolute path.

Wow, searched all day for that and no one on the web had it either. Thanks so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.