Solved

How to prompt to save pdf instead of opening it in browser?

Posted on 2007-11-30
4
1,637 Views
Last Modified: 2013-12-12
I have pdf links on php pages, but i wanna let user download it instead of opening it directly when clicked. How?
0
Comment
Question by:jtcy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20380775
You will need to use php to force download.
Instead of pointing the user to the pdf , point them to a php file with the following code
<? 
    $path = "path/to/file";
	$file = "file.pdf";
 
	header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Length: ' . filesize($path.DIRECTORY_SEPARATOR.$file));
    header('Content-Disposition: attachment; filename=' . $file);
    readfile($path.DIRECTORY_SEPARATOR.$file); 
	
	?>

Open in new window

0
 

Author Comment

by:jtcy
ID: 20380855
I tot there is a way without using php? I heard smth like just inserting a line in the meta field...
0
 
LVL 20

Expert Comment

by:steelseth12
ID: 20380867
Not that i am aware of.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question