>Is it possible to send a file to a browser?
>I would like to allow people to download a file, but I don't want to give
away the path to >the file, so a normal link wouldn't work.
>I am hoping there is a way to use php to send the file using code, rather
than trying to >first copy the file to a temp dir then give them the link,
then worry about deleting the temp >dir again.

<A
HREF=yoursite.com/download.php/whatever.doc?filename=whatever.doc>whatever.d
oc</A>

(Yes, that extra whatever.doc in the URL is on purpose.  Microsoft sucks.)

<?php
    #download.php:

    #This header forces a download:
    header("Content-type: application/octet-stream");

    #This header convinces some browsers to prompt with whatever.doc instead
of download.php:
    header("Content-disposition: $filename");

    #There are about 6 more headers to convince other browser versions of
the same...
    #Look in the code archives for them.

    passthru("/secret/path/not/in/your/website/$filename);
?>

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to