Maison > Article > développement back-end > php 接收到其他文件的重定向输出
php 接收到其他文件的重定向输出
if(is_file($filename)){ $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (in_array($extension, array('png', 'gif', 'jpeg' , 'jpg'))) { header("Content-Type: image/".$extension); } else { if($extension == 'css') header("Content-Type: text/css"); if($extension == 'js') header("Content-Type: application/x-javascript"); } header("Cache-Control: private, max-age=".$browser_cache); header('Expires: '.gmdate('D, d M Y H:i:s', time()+$browser_cache).' GMT'); header('Content-Length: '.filesize($filename)); $length = filesize($filename); $result = readfile($filename); readfile($filename); exit(); }