Home >Backend Development >PHP Tutorial >PHP implements the method of changing the image to open directly for download, _PHP tutorial

PHP implements the method of changing the image to open directly for download, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 09:57:16961browse

PHP implements the method of changing the picture to be directly opened for download.

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&#63;file=pic.jpg">Image goes Here</a>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984003.htmlTechArticlephp method to change the picture to open directly for download. This article describes the method of php to change the picture to open directly for download. method. Share it with everyone for your reference. The details are as follows: p...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn