request->url; "/> request->url; ">
Home > Backend Development > PHP Tutorial > php&cakephp显示图片的有关问题

php&cakephp显示图片的有关问题

WBOY
Release: 2016-06-13 12:32:48
Original
1005 people have browsed it

php&cakephp显示图片的问题
参考:http://bbs.csdn.net/topics/360220433

private function outputFile2Brower(){
        $filename=   WWW_ROOT."../../".$this->request->url;
        if (!file_exists($filename)) {
            throw RuntimeException("File $filename not found");
        }
        //TODO:这里应该智能判断type字符串
        /*这个做法不对,容易导致一些图片无法显示
        header("Content-Type:image/jpg");
        header("Content-Length: ".filesize($filename));
        readfile($filename);*/
        $image = file_get_contents($filename);
        //$content=addslashes($image);
        header('Content-type: image/jpg');
        echo $image;
    }
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template