Analysis of PHP File download processing method

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.