Home >Backend Development >PHP Tutorial >PHP implements the method of changing the image to open directly for download, _PHP tutorial
This article describes the example of php to implement the method of changing the picture to be directly opened for download. Share it with everyone for your reference. The details are as follows:
The process.php file is as follows:
$file = $_GET['file']; header("Content-type: octet/stream"); header("Content-disposition:attachment;filename=".$file.";"); header("Content-Length:".filesize($file)); readfile($file); exit;
The html file is as follows:
<a href="process.php?file=pic.jpg">Image goes Here</a>
I hope this article will be helpful to everyone’s PHP programming design.