Make a $new_filename and put that in the header:

$neW_filename = "downloadfile." . $filetype;
header("Content-Disposition: attachment; filename=$new_filename");
(the content of the file is now in $content, so if you like you could also change the value of $filename if you preferrer that)

You'll need to detect $filetype from $filename to always have the same filename as the original file.


Php Developer wrote on 14/03/2010 21:29:

I'm using the following code:
$fp      = fopen($filename, 'r+');
$content = fread($fp, filesize($filename));
header("Content-type: application/msword"); header("Content-Disposition: attachment; filename=$filename");
echo $content;

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

Kind regards
Kim Emax - masterminds.dk

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

Reply via email to