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.