Question : Download outside root with header()

I have code (attached) that I used to download pdf files outside the root directory. This is done because users are required to login. I am having to transfer the site to a new server and I have everything working right except for this part. When a link is clicked to download a file I get the following error in adode acrobat:

Acrobat could not open 'file.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).

When trying to down an msword .doc file I get the scribble text characters.

My previous server was FreeBSD and my new server is Red Hat.

I'm not sure if there are any setting I must change.

Thank you.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
$dl_path = '/home/myweb/www/download/';
$filename = 'classes.pdf';
$file = $dl_path.$filename;

// then serve the file to the user
$data = file_get_contents( $file );
if ( $data === false ) 
{
 echo '<div>Error: could not read file!</div>';
 exit;
}
header('Content-type: application/pdf');
header("Content-disposition: attachment; filename=$filename" );
echo $data;

Answer : Download outside root with header()

Have you tried the client running the latest rdp client with printer redirection enabled. ?
Random Solutions  
 
programming4us programming4us