Know how to download the file path from the browser (the file is a source file)

Source: Internet
Author: User
Know how to download the file path from the browser (the file is the source file). at the end of this post, u013293559 is edited from 2014-02-. learn how to download the file path from the browser (the file is the source file) please give me some advice .................... know how to download the file path from the browser (the file is a source file)
At the end of this post, u013293559 Edited on 12:11:05 to know how to download the file path from the browser (the file is a source file) ask the gods to help you ......................
------ Solution --------------------
Header ('content-Disposition: attachment; filename = test. php ');
Readfile ('A. php'); // target file
------ Solution --------------------

$ File_dir = ''; // defines the file path.
$ File_name = ''; // defines the file name
$ File = fopen ($ file_dir. $ file_name, "r"); // open the file
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Accept-Length:". filesize ($ file_dir. $ file_name ));
Header ("Content-Disposition: attachment; filename =". $ file_name );
// Output file content
Echo fread ($ file, filesize ($ file_dir. $ file_name ));
Fclose ($ file );
Exit ();
?>

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.