PHP file download function _ PHP Tutorial

Source: Internet
Author: User
PHP provides the file download function. This is the html code. this is mainly used for PHP to download the content of this site. it puts the files to be downloaded and the PHP code page in the same directory, hoping to help more people, if you have any questions, this is the html code, which is mainly used to download the content of this site in PHP. put the file to be downloaded and the PHP code page in the same directory, I hope to help more people. if you have any questions, please contact QQ: 523132661 and wait for your visit at any time. Have a good job.

Download broadband troubleshooting manual

Below is the word. php page

If (! Isset (GET ["file"]) |! Isset (GET ["type"]) {

Print "no file selsect"; exit ();

}

$ File = GET ["file"]. ".". GET ["type"];

If (@ $ fp = fopen ($ file, 'r ')){

Header ("Content-type: octet/stream ");

If (strstr (SERVER ["HTTP_USER_AGENT"], "MSIE ")){

Header ("Content-Disposition: filename =" .mb_convert_encoding('broadband user fault diagnosis manual .doc ', 'gb2312', 'utf-8'); // For IE

} Else {

Header ("Content-Disposition: attachment; filename =" .mb_convert_encoding('broadband user fault diagnosis manual .doc ', 'gb2312', 'utf-8'); // For Other browsers

} While (! @ Feof ($ fp )){

Echo fread ($ fp, 1024 );

} Www.2cto.com

// @ Fpassthru ($ fp );

Exit ();

} Else {

Print "this file does not exist ";

}

From Spring column

Ghost is mainly used for PHP to download content from this site. it puts the files to be downloaded and the PHP code page in the same directory, hoping to help more people, if you have any questions...

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.