Home >Backend Development >PHP Tutorial >php 接收到其他文件的重定向输出

php 接收到其他文件的重定向输出

WBOY
WBOYOriginal
2016-06-20 13:02:061364browse

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();
}

 


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn