Forum Moderators: mack

Message Too Old, No Replies

How to make pdf into download link

how to set up download link

         

genuiner

8:02 am on Aug 4, 2006 (gmt 0)

10+ Year Member



Hi

Very new to webmaster-ing.

I have set up a folder on my server for downloading free pdf's and other files >>> www.mydomain.com/downloads/abc.pdf

When clicked on, it opens up the pdf.

How can I set it up so that when it is clicked on, they get the standard box popping up and asking if they want to "run" or "save", instead of it opening automatically?

thanks in advance

pmkpmk

8:17 am on Aug 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't be done by you - it's a setting inside advanced browsers. However most users are used to the fact that if they click on a PDF the reader opens.

Welcome to WebmasterWorld, by the way!

mack

11:55 am on Aug 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You could have a link "download this PDF file" and have it linked to a zip archive containing it. This is a workaround.

Mack.

genuiner

7:44 am on Aug 8, 2006 (gmt 0)

10+ Year Member



pmk and mack...thanks heaps for your help

Angelis

8:22 am on Aug 8, 2006 (gmt 0)

10+ Year Member



Couldnt you stick ftp:// in front of it instead of [?...]

Angelis

8:23 am on Aug 8, 2006 (gmt 0)

10+ Year Member



That wont work by the way unless you setup an anonymous ftp server and stick it in the right place.

itnecor

5:56 pm on Aug 9, 2006 (gmt 0)

10+ Year Member



try this:
in the page where you put put the links to each pdfs, place the link to each pdfs as:
<a href="downloader.php?dfile=thepdffile.pdf">sample</a>
.
.
.

then the downloader.php will contain the following;

$dfile = $_GET['dfile'];
$path = 'http://www.yourdomain.com/'."your_pdf_folder".'/';
$ffile = "$path"."$dfile";
header('Content-type: application/pdf');
header("Content-Disposition: inline; filename=$dfile");
readfile("$ffile");

jay5r

6:14 pm on Aug 9, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



I've done the same thing with JPGs. I have a case where I want people to download the JPG, not view it in their browser. Here's what I do (just do the equivalent for pdf)...

First, I changed the extension on the file to jpgx.
Then I added the following line to my httpd.conf file:

AddHandler send-as-is jpgx

Then I modifed the jpg file by adding HTTP header info to the top of the file (followed by a blank line). It looks like this:

Status: 200 OK
Last-Modified: Fri, 25 Mar 2005 03:57:53 GMT
Content-Length: 208002
Content-Type: image/jpeg
Content-Disposition: attachment; filename=3600.jpg

The most important part is the last line - It tells the browser to download it (not display it), and it tells it a corrected file name - so the jpgx turns into jpg.

Even in a shared hosting environment where you don't have access to the httpd file you may be able to use the extension .asis since that's an Apache default extension for doing what I just described.

That approach works in just about all cases except IE for Mac. If I encounter IE for Mac I zip the file and have them download a zipped jpg.