You can also use this script if you want to hide the path of files on your server from the users.
- Code: Select all
<?
@ini_set("max_execution_time", 0);
// File Name with complete path
// $sFile = "";
$fFileSize = @filesize($sFile);
if(ini_get('zlib.output_compression'))
@ini_set('zlib.output_compression', 'Off');
header('Content-Description: File Transfer');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header('Content-Type: application/force-download');
header("Content-Type: application/download");
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"".@basename($sFile)."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $fFileSize");
@readfile($sFile);
?>