PHP Server prompt download function to solve the idea

Source: Internet
Author: User
Tags php server
PHP Server prompt Download function
I here is the PC server, and now other computers to visit me here, need to prompt the download function, how to implement it?

It's like writing a download in index.php? There is no experience at all, and I do not know what to do.

I added this section.

PHP Code
  
   
  
   


And then what to do?

------Solution--------------------
Then visit this page on another computer.
------Solution--------------------
Do you want to make a link directly with HTML code?
------Solution--------------------
Filename=aa.rar//A name is to be taken here. Otherwise the RAR file will be formed.
------Solution--------------------
PHP code
 #down. Php$file = ' asdfggg.pdf '; _download ("Files_dir /". $file, $file); function _download ($f _location, $f _name) {header (" cache-control:must-revalidate, post-check=0, pre-   Check=0 ");   Header (' Content-description:file Transfer ');   Header (' Content-type:application/octet-stream ');   Header (' Content-length: '. FileSize ($f _location));   Header (' content-disposition:attachment; Filename= '. basename ($f _name));  ReadFile ($f _location);
   
------Solution--------------------
discussion

I added these 3 lines of code to the localsettings.php:
PHP Code

Header ("Content-type:application/rar");

Header ("Content-disposition:attachment;filename=sqlite.rar");

ReadFile ("E:\ziptest\SQLite.rar");


Login to the first page, there is a download prompt, but ...
  • 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.