下载功能实现方式

/******下载*****/

function down($file){

//ob_start();

$file="/Application".str_replace(APP_PATH,"",$file);

header("Location:$file");

exit();

if (file_exists($file)) {

header('Content-Description: File Transfer');

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename='.date("YmdHsi").".xls");

header('Content-Transfer-Encoding: binary');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Pragma: public');

header('Content-Length: ' . filesize($file));

ob_clean();

flush();

readfile($file);

exit;

}

}

你可能感兴趣的:(下载功能实现方式)