How do I get my website to open up a pdf outside of a visitors web browser?

JAFL

New Member
I have a website with a link to a pdf. Currently, when a visitor clicks on the link, it opens the pdf inside the web browswer. I would like the the link instead to launch acrobat and open the pdf outside of their web browser.

Does anyone know how to fix this?
 

andy faith

New Member
I'm not sure you can. It's acrobat reader that opens it inside your browser as a kind of a plug-in for it, so I'm not sure if you can get it to open in the seperate window.
 

JAFL

New Member
I'm not sure you can. It's acrobat reader that opens it inside your browser as a kind of a plug-in for it, so I'm not sure if you can get it to open in the seperate window.

I'm trying to force a download. I've seen it done. And I've read that there's an html script to do it. I just don't know what the script is or where to place it in the code.
 

apj101

VIP Member
it cant be done in HTML, you have to do it through a php script

eg
here is the php script lets call in plop.php
PHP:
<?
$file = $_GET['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
?>

and then you call it by
<a href="plop.php?file=picture.jpg">Download JPG image</a>
 

JAFL

New Member
it cant be done in HTML, you have to do it through a php script

eg
here is the php script lets call in plop.php
PHP:
<?
$file = $_GET['file'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
?>

and then you call it by
<a href="plop.php?file=picture.jpg">Download JPG image</a>

Ok, considering i'm a complete novice at this, where would I place this? I have dreamweaver, can I place it within the body of the code in dreamweaver?
 

apj101

VIP Member
Ok, considering i'm a complete novice at this, where would I place this? I have dreamweaver, can I place it within the body of the code in dreamweaver?

no, you put the php code in a text file, save it as plop.php then upload that to your web server and place the html code on any web page you want a download from
be sure to adjust the path of the href to match where you put the php file, and the path of the picture/pdf/other to match its location
 

JAFL

New Member
no, you put the php code in a text file, save it as plop.php then upload that to your web server and place the html code on any web page you want a download from
be sure to adjust the path of the href to match where you put the php file, and the path of the picture/pdf/other to match its location

Sorry to be a pain in ass, but most of that was way over my head.

I understand everything through uploading it to my web server. After that....

How do I place html code on any web page? (and what html code are you referring to?).

How do I adjust the path of the href (what is the href?)
 

Cromewell

Administrator
Staff member
Your webserver needs to support php for this to work.

The code you put on your html is like this:
<a href="plop.php?file=picture.jpg">Download JPG image</a>
Say you wanted to open a file called newwindow.pdf. You could put html on your page like this: <a href="plop.php?file=newwindow.pdf">New Window PDF</a>
 

JAFL

New Member
Your webserver needs to support php for this to work.

The code you put on your html is like this:

Say you wanted to open a file called newwindow.pdf. You could put html on your page like this: <a href="plop.php?file=newwindow.pdf">New Window PDF</a>

Is there a way to code this in such a way so that someone can just click on my logo or other image? I tried a code similar to this someone gave me, but it just created text on my index page. Problem is, I don't want text, I just want an image to link it.
 

Cromewell

Administrator
Staff member
Just replace the text with an image instead.
<a href="plop.php?file=newwindow.pdf"><img border=0 src="imagelink.jpg"></a>
 

JAFL

New Member
Just replace the text with an image instead.
<a href="plop.php?file=newwindow.pdf"><img border=0 src="imagelink.jpg"></a>

I must be doing something wrong, because no matter which one (text or image) I place in the code, it just displaces one of my slices. I must have placed the code in the wrong place.

How do I know 'where' to place the code so that none of my existing slices are displaced?
 
Top