PDA

View Full Version : download link


RainForest
04-07-2011, 06:06 PM
Hello,

I'm trying to create a link that doesn't just open a pdf file, but actually prompts the user to download the file. Is there a way to do this?

gentleone
04-07-2011, 06:20 PM
You can force a download dialog using PHP. Here's a neat article about the subject.
http://apptools.com/phptools/force-download.php

RainForest
04-07-2011, 07:36 PM
Thanks, gentleone. That's a comprehensive page. I've followed the instructions but still just get the pdf file to open in the browser instead of getting the download dialog. Am I supposed to modify the code somewhere?

gentleone
04-07-2011, 08:14 PM
Can you post the code what you have so far, so I can have a look?

Ricky55
04-07-2011, 08:48 PM
What browser are you using? I have some code that works in all browsers apart from Safari.

You could also zip the PDF that forces the download too but not ideal.

I would advise against doing this anyway though. Im never keen on altering the way a browser works for things of this nature. To my mind there's nothing wrong with the PDF just opening in the browser in fact it's more convenient. Unless it's a huge file.

Users expect the PDF to open and can be put off if asked to download something.

d a v e
04-07-2011, 10:17 PM
and of course users can choose to right click and save as

RainForest
04-08-2011, 12:56 AM
gentleone, the code I posted is /exactly/ what appears in the link you provided.

Ricky, /my/ browser of choice is FF, but I also checked in IE & no go.

domedia
04-08-2011, 04:42 PM
I would advise against doing this anyway though. Im never keen on altering the way a browser works for things of this nature. To my mind there's nothing wrong with the PDF just opening in the browser in fact it's more convenient. Just want to agree with this. Let the user decide how they want to approach it.

RainForest
04-08-2011, 10:31 PM
I suppose it really makes no difference how the file is accessed. I wanted to make it a download because the associated link says "click here to download survey". They can't complete the survey in the web browser, so it's just an unnecessary step I was trying to avoid for the visitor.

DWcourse
04-09-2011, 12:52 AM
I suppose it really makes no difference how the file is accessed. I wanted to make it a download because the associated link says "click here to download survey". They can't complete the survey in the web browser, so it's just an unnecessary step I was trying to avoid for the visitor.

Why not:

"right+click here to download survey"

Ricky55
04-10-2011, 06:40 PM
Or even better but more work make the survey a web page with a form that they can complete online.

RainForest
04-11-2011, 04:35 PM
Why not:

"right+click here to download survey"

That's an excellent suggestion: right click and save target as. Thanks!


Or even better but more work make the survey a web page with a form that they can complete online.
I'd like to do this, but I'm terrible with forms. It's on my list to learn soon.

domedia
04-12-2011, 09:44 PM
I suppose it really makes no difference how the file is accessed. I wanted to make it a download because the associated link says "click here to download survey". They can't complete the survey in the web browser, so it's just an unnecessary step I was trying to avoid for the visitor.

I would argue that you're still limiting the user. What if they don't want to initiate the download window? What if they want to use their browser preference if that is viewing it in the browser? And then download it to their download directory if they think it's interesting.

edbr
04-13-2011, 02:23 AM
you can do it with php and offer 2 links, open file or download

heres an untried script http://www.zubrag.com/scripts/download.php

edbr
04-13-2011, 02:27 AM
or guru Olaf lederer
http://www.finalwebsites.com/forums/topic/php-file-download