How to get IE to download PDF files instead of opening them directly

Source: Internet
Author: User
For example, there is a PDF file on a server: http://www.xxx.com/abc.pdf
Then ABC, click on the hyperlink under IE, will open the PDF file directly, how can I pop the download box under IE, instead of opening it directly? What do you do with PHP (or JS)?


Reply to discussion (solution)

 
 

oo.php

$file _path= ' test.pdf '; $file _name= ' test.pdf '; $fp =fopen ($file _path, "R"); $file _size=filesize ($file _path); Header (" Content-type:application/octet-stream "), Header (" Accept-ranges:bytes "), Header (" Accept-length: $file _size "); Header ("Content-disposition:attachment;filename=". $file _name); $buffer =1024; $file _count=0;while (!feof ($FP) & & ($file _size-$file _count>0) {$file _data=fread ($fp, $buffer); $file _count+= $buffer; echo $file _data;} Fclose ($FP);

Thank you jam00, this has been tossing me for several days

  • 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.