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.he...@gmail.com [mailto:richard.he...@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




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to