public function dw($url,$name){
$file_url = ROOT_PATH.'/public'.$url;
$out_filename = $name.'.'.getExt($file_url);
if(!file_exists($file_url)) {
echo "不存在";
}else{
header('Accept-Ranges: bytes');
header('Accept-Length: ' . filesize( $file_url ));
header('Content-Transfer-Encoding: binary');
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $out_filename);
header('Content-Type: application/octet-stream; name=' . $out_filename);
if(is_file($file_url) && is_readable($file_url)){
$file = fopen($file_url, "r");
echo fread($file, filesize($file_url));
fclose($file);
}
}
}
function getExt($file){
return end(explode(".",$file));
}