How to use PHP to force file Upload

Source: Internet
Author: User
How to use PHP to force File Download PHP allows you to change what you write, so that you can force a file to be downloaded, usually, the browser loads the HTTP header of the file in the same window. This is perfect for files, such as PDF files, document files, images, and videos. you want your customers to download them instead of reading them online. The specific method is as follows: 1. you want to download the file to your Web server. For example, huge_document1_2 is used to edit how to use PHP to force file download.

PHP allows you to change what you write, which forces an object to be downloaded. Normally, the browser loads the HTTP header of the object in the same window. This is perfect for files, such as PDF files, document files, images, and videos. you want your customers to download them instead of reading them online.
The specific method is as follows:

1. you want to download the file to your Web server. For example,

Huge_document.pdf

2. edit the new PHP file. I suggest you name it the file you downloaded with the same name, just for PHP extension. For example:

Huge_document.php

3. open the PHP module:

<? PHP

4. set the HTTP header in the next line:

Header ('content-disposition: attachment; filename=huge_documentate ');

5. set the MIME type of the file:

Header ('content-type: application/pdf ');

6. point to the file you want to download:

Readfile('huge_document ');

7. disable the PHP block and save the file:

> [/BLOCKQUOTE>

8. your php file should be like this:

Header ('content-disposition: attachment; filename=huge_documentate ');

Header ('content-type: application/pdf ');

Readfile('huge_document ');

?>

9. download link to your php file. For example:

Download huge files (PDF)
Address: http://www.software8.co/wzjs/PHPshili/942.html

Tip:

There should be no space or carriage return in this file. Empty lines will make PHP text/html by default and your files cannot be downloaded.

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.