How to specify filename in header() method with content-type
Posted: Fri Jun 06, 2003 11:29 am
This is a file I use to let users download a file stored elsewhere in the system:
This does not seem to work on IE because the browser doesnt know what to save the filename as. It says "saving getfile.php" and then says it can't, and stops. However, Mozilla 1.3 in linux saves the file (but its named getfile.php). If the saved getfile.php is renamed to blah.zip, then it can be successfully unzipped and it has all the correct contents.
My question is, how do I tell the browser what to name the savefile as? I'm thinking the answer lies in something along these lines:
So that not only does the browser know what the file type is, but also what a suggested save fiel name is.
Code: Select all
<?
//this is file getfile.php
$filename=$_GET['file'];
if(file_exists($filename)){
header("content-type: application/zip");
readfile($filename);
}
?>My question is, how do I tell the browser what to name the savefile as? I'm thinking the answer lies in something along these lines:
Code: Select all
header("content-type: application/zip, content-name: ".$filename);