RE: [PHP] How to change a filename for download (e.g. jpeg, pdf etc.)

From: Date: Fri, 05 Feb 2010 13:30:35 +0000
Subject: RE: [PHP] How to change a filename for download (e.g. jpeg, pdf etc.)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-301830@lists.php.net to get a copy of this message
Hi, I finally got the time to test your solutions, the following is the best solution and causes a minimum stress on the server and a decent security. header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="downloaded.pdf"'); readfile('original.pdf'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past (Script from php.net based on your hints.) I have tested this in many ways, but before I did not know how this was simple. SED -----Original Message----- From: richard.heyes@gmail.com [mailto:richard.heyes@gmail.com] On Behalf Of Richard Sent: 25. janúar 2010 10:16 To: SED Cc: php-general@lists.php.net Subject: Re: [PHP] How to change a filename for download (e.g. jpeg, pdf etc.) Hi, > Can anyone point me to tutorials on how to change a filename for each > download? My goal is to give the downloader a random name for a picture or a > document, so he will never know what the original filename is. Try adding a Content-Disposition header: <?php header('Content-disposition: attachment; filename=fname.ext'); ?> -- Richard Heyes HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 16th January) Follow me on Twitter: http://twitter.com/_rgraph Lots of PHP and Javascript code - http://www.phpguru.org

« previous php.general (#301830) next »