日期:2014-05-17 浏览次数:20552 次
$file_name="test.xls";
$file_path="../data/down/2011/03/21/";
$file_name = urldecode($file_name);
// ../ is not allowed in the file name
if (!ereg("(\.\.\/)", $file_name))
{
// Does the file exist?
if (file_exists($file_path . $file_name))
{
$fp = @fopen( $file_path . $file_name, "r" );
//Prompt the user to download the new torrent file.
header("Expires: 0" );
header("Pragma:public" );
header("Cache-Control:must-revalidate,post-check=0,pre-check=0" );
header("Cache-Control:public");
header("Content-Type:application/octet-stream" );
if (strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")) {
header("Content-Disposition:attachment;filename=".urlencode($file_name) );
}else{
header("Content-Disposition:attachment;filename=".$file_name );
}
header("Content-transfer-encoding: binary");
header("Content-length:".@filesize( $file_path . $file_name ));
@fpassthru( $fp );
@fclose( $fp );
}
exit();
}