How php forces picture downloads by modifying header
This article mainly introduces how php through the modification of header forced picture download, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
The specific implementation methods are as follows:
Function downloadFile ($file) {$file_name = $file; $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 ($file_name).'') Header ('Content-Transfer-Encoding: binary'); header (' Connection: close'); readfile ($file_name); / / push it out exit ();} Thank you for reading this article carefully. I hope the article "how php forces picture downloads by modifying header" shared by the editor will be helpful to you. At the same time, I hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!