PHP实现远程图片下载

 /**
     * 文件下载
     * @param string $url
     */
    public function download() {
        $url = $this->input->get_post('url');
        $fileName = time() . substr($url, strrpos($url, '.'));
        $fileInfo = get_headers($url);
        header('Content-Type: appliaction-octet-stream');   //文件流
        header($fileInfo[4]);                               //文件大小
        header('Content-disposition: attachment; filename=' . $fileName);//文件名称
        readfile($url);
    }

 

posted @ 2015-10-29 16:29  马辉  阅读(271)  评论(0编辑  收藏  举报