Hyperlink download
If the browser supports hyperlinks to download the file, it will automatically download the file when you click the hyperlink.
Here's a test to download the file via the hyperlink:
<a href= "/uploads/test.zip" > Download files via hyperlinks </a><br>
When we click on it, it looks like this:
Hyperlink download File
To download a picture from a hyperlink:
When we download a picture through a hyperlink, it opens the display directly in the browser, and then we need to save it to the specified path:
<a href= "/uploads/qc8054r7qpgq_1000x500.jpg" > Download pictures via Hyperlinks </a><br>
The effect is this:
Hyperlink Download Picture
Download by program
HTML-side line of code
<a href= "download.php?filename=qc8054r7qpgq_1000x500.jpg" > Download picture </a> by program Way
download.php Code
We send the file download information through header request headers, specify to download the attachment, download the filename, content-length to specify the size of the file, and then use the ReadFile function to read the contents of the file and implement the file download:
<?php
$filename = $_get[' filename '];
Header (' Content-disposition:attachment;filename= '. basename ($filename));
Header (' Content-length: ' FileSize ($filename));
ReadFile ($filename);
The effect is as follows: