PDA

View Full Version : HTML Code for downloading files


Jensen
02-07-2005, 01:26 AM
Hi all
I am designing a web site, and I want the users to be able to download various files i.e. in word, powerpoint or (most likely) PDF format.
It seems to be a commonly used feature on many sites, but how do I code it in HTML?
Grateful for any examples you can come up with!

DCElliott
02-07-2005, 04:12 AM
I'd like to add to that question. I have a site with Reference Manager Database files for downloading. Unfortunately the *.rmd extension they have is shared with Real Media files so a 'left' click will download the file and it will try to stream as multimedia. Even though I tell people to 'right' click and Save As, they frequently don't and then complain. Any Idea how to ensure that any click always brings up a Save As dialogue? I've looked for Javascripts that will do the trick but have not been successful at finding something that works. (Although some post talk about what *should* work, but it is obvious they didn't try it!!)

DE

tmmoose
02-07-2005, 09:22 AM
<a href=" file.pdf">Some PDF file</a> Is this what your after or is it more complicated?? :hellother


FOR DC
Download Instruction page (http://tmckee.freeserverhost.com/swf/download.html) :hellother

DCElliott
02-07-2005, 05:44 PM
Moose man - I don't know whether to give you karma or take it away for being such a cheeky bugger. That does get the point across but I don't think I can use it with a bunch of overly serious academics.

DE

tmmoose
02-07-2005, 06:06 PM
LOL :hellother

ishan
11-09-2005, 05:23 AM
The best way to be sure that user will get a download dialog and Adobe Reader will not catch up ur file, is to use a simple PHP script. it forces the browser to open download dialog.


<?php
$file = $_GET['file'];
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=". $file);
readfile($file);
?>

and use this link:
<a href="path_to.php?file=file_name">File Name</a>

SomethingTV.com
06-21-2007, 08:48 PM
I'm trying to use your code to allow users to download video and sound files but can't seem to get the php code to work to allow left click to cause dialog to open.

let's say the file is called space_noise.mp3 Would you mind inserting it properly in the above .pdf example

much thanks in advance. I've been looking all around for this.

stv

Terminator1138
06-22-2007, 07:15 AM
Are you wanting them to force download and open in media player or just to get the mp3?

Do you have your files in the php extension and does your host support php?

Immoral12340
07-09-2007, 04:01 PM
Hi,

I am pretty new here, but to answer your question: If you zip the files first then link to it. I think that should automatically make a download available. I haven't tried this but read it off some other site.

I am sorry if this doesn't help.