How to implement msword and pdf browsing and downloading in php

Source: Internet
Author: User
Php msword and pdf browsing and downloading how to implement the younger brother is doing a teacher to publish the thesis requirements, and then the students upload the thesis website, is a graduation assignment, the teacher has a holiday, can't ask, so I came to you. my website only allows students to upload pdf or msword files and download them, except downlaod. in addition to php, when clicking the File link, the instructor does not necessarily download the file immediately, but opens a browser interface. you can choose to view the file online or download it if necessary, how can I download msword and pdf files in php?
The younger brother is working as a teacher to publish a thesis request, and then the students upload the thesis website, which is a graduation assignment. the teacher has a holiday and can't ask, so he will come to you.
My website only allows students to upload pdf or msword files, which can be downloaded, except downlaod. in addition to php, when clicking the File link, the instructor does not necessarily download the file immediately, but opens a browser interface. you can choose to view the file online or download it if necessary, how can this problem be achieved .... Or is it implemented using js?

------ Solution --------------------
Not very well controlled. Set the header to the browser.


Http://www.cnblogs.com/persy_php/archive/2010/07/21/1782407.html
Http://grow.sinaapp.com /? P = 667

Set the header, similar to the following

Header ('content-Description: File Transfer ');
Header ('content-Type: application/octet-stream ');
Header ('content-Disposition: attachment; filename = '. basename ($ file ));
Header ('content-Transfer-Encoding: binary ');



Header ('content-type: application/pdf ');
Header ('content-Disposition: attachment; filename = "downloaded.pdf "');
Readfile('original ');

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.