Re: IE download problem
| From: | pete M | Date: | Wed, 26 Nov 2003 16:51:47 +0000 |
| Subject: | Re: IE download problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-171095@lists.php.net to get a copy of this message | ||
thsi si a nighmare area..... and loast days on same problem
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