Home >Backend Development >PHP Problem >When php clicks on a link, it downloads instead of opening it.
php method to realize that clicking a link downloads instead of opening it
Hyperlink connected to txt text , do not open it directly but download it after clicking
Two processing methods on the server side, one is to set it in a server such as apache or iis or tomcat, or specify the sending type in the program.
This information belongs to http header information, and PHP has a function to directly operate the header information.
How to implement php:
The code is as follows:
<?php header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename($_GET['url'])); readfile($filename); ?>
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of When php clicks on a link, it downloads instead of opening it.. For more information, please follow other related articles on the PHP Chinese website!