The above code is the download code
Next, paste the code for previewing PDF files online.
Copy codeThe code is as follows:
Public function fddAction ()
{
// Get attachment location
$ Attachment_location = $ _ SERVER ["DOCUMENT_ROOT"]. "/pdf/fdd/sample.pdf ";
If (file_exists ($ attachment_location )){
// Attachment exists
// Send open pdf dialog to user
Header ('cache-Control: public '); // needed for I. e.
Header ('content-Type: application/pdf ');
Header ('content-Disposition: inline; filename = "sample.pdf "');
Readfile ($ attachment_location );
Die (); // stop execution of further script because we are only outputting the pdf
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.