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

php通过修改header强制图片下载

2017-04-06 17:24 288 查看
$file_name = $imgUrl;//图片链接

$mime = 'application/force-download';

header('Pragma: public'); // required

header('Expires: 0'); // no cache

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Cache-Control: private',false);

header('Content-Type: '.$mime);

header('Content-Disposition: attachment; filename=1.png');

header('Content-Transfer-Encoding: binary');

header('Connection: close');

readfile($file_name); // push it out

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