This works for me.. hope it does for you
$file = $_GET['file']; $path = '/www/cgi-bin/docu/personal/'.$file; //force download dialog header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=\"$file\"\n"); header("Content-transfer-encoding: binary\n"); header("Content-length: " . filesize($path) . "\n");
//send file contents $fp=fopen($path, "r"); fpassthru($fp);
Luis Lebron wrote:
I am working on a script to force downloading a file. The script works fine with NS (4.8 and 7) but does not work correctly with IE 6.0 I have looked at examples on php.net and have googled for a solution, but still can't find a solution. I think IE wants to download the script instead of the file.
Here's what the code I'm working on looks like:
<?php $sender=$_GET["sender"];
$filename=$_GET["filename"];
//Data validation goes here
$filePath="../users/".$sender."/".$filename;
if(file_exists($filePath))
{
Header("Content-Length: ".filesize($filePath));
Header("Content-type: application/download");
Header("Content-Disposition-type: attachment");
Header("Content-Disposition: filename=\"".$filename."\"\n");
Header("Content-Transfer-Encoding: binary");
$fp = fopen($filePath,"rb");
fpassthru($fp);
} ?>
The funny thing is that I have a similar script that I use to download an sql file and it works correctly.
Luis R. Lebron Sigmatech, Inc
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php