header-thinkphp How to implement pop-up window download

Source: Internet
Author: User
Tags readfile
Header ("Pragma:public");
Header ("cache-control:max-age=". $expire);

Header (' Cache-control:no-store, No-cache, Must-revalidate ');
Header ("Expires:".) Gmdate ("D, D M Y h:i:s", Time () + $expire). "GMT");
Header ("last-modified:".) Gmdate ("D, D M Y h:i:s", Time ()). "GMT");
Header ("content-disposition:attachment; Filename= ". $showname);
Header ("Content-length:". $length);
Header ("Content-type:". $type);
Header (' Content-encoding:none ');
Header ("Content-transfer-encoding:binary");
if ($content = = ") {
ReadFile ($filename);
}else {
Echo ($content);
}
Exit ();

This is a piece of code inside HTTP, but I can only read it out to the browser. Do you have any way to click on the link such as "Download" will appear a box and then enter the name of the save it?

Reply content:

Header ("Pragma:public");
Header ("cache-control:max-age=". $expire);

Header (' Cache-control:no-store, No-cache, Must-revalidate ');
Header ("Expires:".) Gmdate ("D, D M Y h:i:s", Time () + $expire). "GMT");
Header ("last-modified:".) Gmdate ("D, D M Y h:i:s", Time ()). "GMT");
Header ("content-disposition:attachment; Filename= ". $showname);
Header ("Content-length:". $length);
Header ("Content-type:". $type);
Header (' Content-encoding:none ');
Header ("Content-transfer-encoding:binary");
if ($content = = ") {
ReadFile ($filename);
}else {
Echo ($content);
}
Exit ();

This is a piece of code inside HTTP, but I can only read it out to the browser. Do you have any way to click on the link such as "Download" will appear a box and then enter the name of the save it?

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

or modify the httpd mime.types inside the corresponding file type is Application/octet-stream

  • Related Article

    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.