|
Posted by Rik on 12/18/97 11:48
Dynamo wrote:
> Many thanks but somehow I dont think that snippet of code on its own
> will do what I want. I was looking for the complete code. I have
> tried the following but it failed miserably. What am I doing wrong?
>
> <?php
> $dir_name = "/books/";
> $file = "downloadtest.pdf";
>
> $content = file_get_contents($dir_name . $file);
>
> header('Content-Type: pdf');
> header('Content-Length: ' . filesize($dir_name . $file));
> header('Content-Disposition: 'attachment');
> echo $content;
1. Turn on error reporting, if this is you script, it will tell you some
interesting things.
2. Is /books/ in your root? If not, you can't refer to it like this. Does
content indeed hold the file, or just 'false"?
Also:
it's header('Content-type: application/pdf');
The exact syntax is in the php-manual as an example for header...
http://nl3.php.net/en/header
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="name_give_to_user.pdf"');
readfile('/path/to/original.pdf');
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|