Re: Force file download with header
| From: | Chris Shiflett | Date: | Mon, 06 Jan 2003 21:47:06 +0000 |
| Subject: | Re: Force file download with header | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130497@lists.php.net to get a copy of this message | ||
--- Altug Sahin <altug@bonsai-apart.com> wrote:
> <?
> $file = $_POST[fileID];
> $files_folder = "C:\\temp\\";
> $dlfile = $files_folder.$file;
>
> header("Content-type: application/pdf");
> readfile("$dlfile");
> ?>
>
> I get this...
> "Warning: readfile("C:\temp\test.pdf") - No such file or
> directory in c:\inetpub\wwwroot\dlQ_safe.php on line 10"
>
> The test.pdf file is of course there...
My guess is that the test.pdf file is of course not there.
You can try to use file_exists() if you do not trust the
warning message, but I see no reason not to trust it.
> What do I need to add to this script so that whatever a
> pdf filename is submitted, acrobat will open this file
> in the user's browser?
This is a different question, but search for examples on
using the Content-Disposition header. I believe there is a
directive called "inline" that you can give it to try to
force a browser to display the content inline rather than
prompt for a download.
Chris