[PHP] php通过修改header强制图片下载的代码 →→→→→进入此内容的聊天室

来自 , 2021-02-17, 写在 PHP, 查看 123 次.
URL http://www.code666.cn/view/ce47be4a
  1. function downloadFile($file){
  2. $file_name = $file;
  3. $mime = 'application/force-download';
  4. header('Pragma: public'); // required
  5. header('Expires: 0'); // no cache
  6. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  7. header('Cache-Control: private',false);
  8. header('Content-Type: '.$mime);
  9. header('Content-Disposition: attachment; filename="'.basename($file_name).'"');
  10. header('Content-Transfer-Encoding: binary');
  11. header('Connection: close');
  12. readfile($file_name); // push it out
  13. exit();
  14. }
  15.  
  16.  

回复 " php通过修改header强制图片下载的代码"

这儿你可以回复上面这条便签

captcha