Ammar
On 7/1/06, rami_yacoub <[EMAIL PROTECTED]> wrote:
try to use this code
<?php
$filename = $_GET['file'];
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression') )
ini_set(' zlib.output_compression', 'Off');
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if ( $filename == "" ) {
echo "<html><body>ERROR: download file NOT SPECIFIED. USE
fileName.php?file=filepath</body></html>";
exit;
} elseif ( ! file_exists( $filename ) ) {
echo "<html><body>ERROR: File not found. USE
fileName.php ?file=filepath</body></html>";
exit;
}
switch ( $file_extension ) {
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
header("Cache-Control: private",false); // required for certain
browsers
header("Content-Type: $ctype");
// change, added quotes to allow spaces in filenames
header("Content-Disposition: attachment;
filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Jordan PHP Users Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/JoPHP
http://Jolug.org/
-~----------~----~----~----~------~----~------~--~---
- [JoPHP] Download Script and IE Ala'a Ibrahim
- [JoPHP] Re: Download Script and IE Ammar Ibrahim
- [JoPHP] Re: Download Script and IE Ala'a Ibrahim
- [JoPHP] Re: Download Script and IE Ammar Ibrahim
- [JoPHP] Re: Download Script and IE hafez ahmad
- [JoPHP] Re: Download Script and IE rami_yacoub
- [JoPHP] Re: Download Script and IE Ammar Ibrahim
- [JoPHP] Re: Download Script and IE Ala'a Ibrahim
- [JoPHP] Re: Download Script and IE Ammar Ibrahim
