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

Source: Internet
Author: User
How to let IE download PDF files instead of opening them directly, for example, there is a PDF file on a server: http://www.xxx.com/abc.pdf
Then abc, click the hyperlink under IE to open the PDF file directly. how can I bring up a Download box in IE instead of opening it directly? How to use php (or js?


Reply to discussion (solution)

 

Oo. php

Using file_path='test.w.'{{file_name='test}'; $ 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 );

Thanks to jam00. I 've been tossing this 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.