|
Posted by Chuck Anderson on 01/11/08 21:29
firewoodtim@yahoo.com wrote:
> I want to display an uploaded file (e.g. a pdf file) in a "_blank"
> target window. The file is stored outside of the webroot at
> "/home/myhome/uploads/" and was uploaded by a trusted user with the
> function, move_uploaded_file().
>
> I've checked out readfile(), but there is scant info in the way of
> examples on php.net. Can anyone help with some code?
>
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Length: ' . filesize($file));
// pick one
// to download
// header('Content-Disposition: attachment; filename=' . basename($file));
// to open in browser
// header('Content-Disposition: inline; filename=' . basename($file));
readfile($file);
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Nothing he's got he really needs
Twenty first century schizoid man.
***********************************
Navigation:
[Reply to this message]
|