Analysis of PHP File download processing method
This article mainly introduces the php file download processing method, example analysis of PHP for file download common processing skills, with a certain reference value, the need for friends can refer to the
This article describes the php file download processing method. Share to everyone for your reference. The specific analysis is as follows:
PHP can handle a variety of conditional file downloads, first look at the following example:
?
| 1 2 3 4 5 |
<?php header ("Content-type:application/force-download"); Header ("content-disposition:attachment; Filename=testname.jpg "); ReadFile ("images/test.jpg");?> |
Analyze the above code:
The first line of code is a forced download;
The second line of code is to specify a name for the downloaded content;
The third line of code is to read the downloaded content into the file.
Always thought it was impossible to download multiple files at the same time in one page, since PHP's first header sent the download message and it could not be sent again.
Today we finally know a solution that uses an IFRAME to implement it.
?
| 1 2 3 4 |
<iframe src= "1.zip" style= "border-style:none;width:0;height:0;" > </iframe> <iframe src= "2.zip" style= "border-style:none;width:0;height:0;" > </iframe> |
You can also use JS to generate an IFRAME
I hope this article will help you with your PHP program design.