您的位置:首页 > 编程语言

点击a链接下载附件代码

2015-09-08 17:58 176 查看
//下载附件,file 为附件地址

    public function actionDownload(){

        

        if(!fopen('http://'.$_GET['file'],'r')){

            die('图片不存在');

        }

        $filename = 'http://'.$_GET['file'];//图片地址,可以绝对地址也可以相对地址

        header("Content-Type: application/force-download");

        header('Content-Disposition: attachment; filename="'.$filename.'"');

        $img = file_get_contents($filename); 

        echo $img;

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  代码