Click to See Complete Forum and Search --> : Downloaded file name


Igor Yalovecky
August 19th, 2010, 10:50 AM
<?
$mime = mime_content_type($path);
header('Content-type: ' . $mime);
readfile($path);
?>
All goes right except if it file must be downloaded then it downladed with name of my php file. Can i say to browser another name?

PeejAvery
August 19th, 2010, 11:09 AM
If you want to force a download, you better use a few more headers...

header('Content-Disposition: attachment; filename="' . basename($file) . '";' );
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . @filesize($file));