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

php教程评论602 views阅读模式
  1. unction 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');

复制代码

企鹅博客
  • 本文由 发表于 2019年9月9日 04:22:51
  • 转载请务必保留本文链接:https://www.qieseo.com/315653.html

发表评论