编程爱好者之家

php实现点击图片另存为功能

2019-04-23 62

php实现点击图片另存为功能如下

$file = $filename = 'https://www.codelovers.cn/static/Home/images/404.jpg';
$out_filename = 'newfilename.jpg';


$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="'.basename($filename).'"');
header('Content-Type: application/octet-stream; name=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile($filename); 
exit();


同类文章

您的赞赏是对小编最大的支持!