Re: Change displayed file name to download
| From: | Peter Lind | Date: | Sun, 14 Mar 2010 20:43:01 +0000 |
| Subject: | Re: Change displayed file name to download | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302813@lists.php.net to get a copy of this message | ||
You can set the name to display as you see fit, just change $filename
to your liking right before the header() call. If you just want to cut
the path, use basename($filename)
Regards
Peter
On 14 March 2010 21:29, Php Developer <pdeveloper@rocketmail.com> wrote:
> Hi,
>
> I'm using the following code:
> ____________________
> $fp = fopen($filename, 'r+');
> $content = fread($fp,
> filesize($filename));
> fclose($fp);
> header("Content-type:
> application/msword");
> header("Content-Disposition: attachment;
> filename=$filename");
> echo $content;
> exit;
> ___________________
>
> Now when downloading a file the default name that appears for the user is
> the realname of the file i the server with the real path the only
> difference is that the slashes are modified by underscore.
>
> My
> question is: is there any way how to control the name that will be
> displayed for the customer? Or at least skip the path and display just
> the file's name?
>
> Thank you
>
>
> __________________________________________________________________
> Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new
> Yahoo! Mail. Click on Options in Mail and switch to New Mail today or register for free at
> http://mail.yahoo.ca
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>