编程爱好者之家
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();