Am using PHP 4.0.6. I have written code for downloading the files thru browser, but it doesn't allow me to download the files. I type http://localhost/dn.php in the browser then it displays File Download Dialogue box saying 'You have chosen to downlaod file from this location.
dn.php from localhost' and gives 2 options either to open from current location and other save this file to disk..
When I select any option and clicks Ok it gives me an error saying 'Internet Explorer cannot download file dn.php'.
Here is the code given below which am using to download files.
<?php
$filename = 'D:/2002Projects/ProdPortal/siteroot/syssrc.zip';
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
readfile($filename);
?>
I have read many forums abt this one and found the solution almost same. But the same code doesn't work for me. I tried the same in Opera and Netscape browsers too. The latest code I wrote is as below; but the same problem arises here too.
<?
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($filename) . "\n");
$fp=fopen($filename, "r");
fpassthru($fp);
?>
and in IE address location I give
http://sandesh/ProductsPortal/dn.php?filename=syssrc.zip
Please help me out of this. Thanks in advance..