Home > Backend Development > PHP Tutorial > Analysis of php file download processing method, _PHP tutorial

Analysis of php file download processing method, _PHP tutorial

WBOY
Release: 2016-07-13 09:56:29
Original
872 people have browsed it

Analysis of php file download processing method,

The example in this article describes the processing method of php file download. Share it with everyone for your reference. The specific analysis is as follows:

php can handle file downloads under various conditions. Let’s take a look at the following example:

<&#63;php
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=testname.jpg"); 
readfile("images/test.jpg");
&#63;>
Copy after login

Analysis of the above code:

The first line of code is forced download;
The second line of code assigns a name to the downloaded content;
The third line of code reads the downloaded content into the file.

I have always thought that it is impossible to download multiple files at the same time in one page, because PHP cannot send download information after the first header.
Today I finally found out a solution, using iframe.

<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>
Copy after login

You can also use js to generate iframe

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/987888.htmlTechArticleAnalysis of php file download processing method. This article describes the php file download processing method in an example. Share it with everyone for your reference. The specific analysis is as follows: php can handle files with multiple conditions...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template