< back

Hyperlinks For Downloads

What is needed to offer links to download files is easy... sort of !

The "a" tag can be used just as successfully to direct the browser to a "MIME" type file:
(i.e. <a href="wallies.zip">Walllies Resume</a>)
as it is for general hyperlinks.

Snazzy/Cool/You-Beaut downloads...
Ever used one of those sites where one page lets you select the download accompanied by a bit of explanatory blurb, sends you to another page with some more stuff on it, and then the download seems to happen automatically via that other page.

Well, on the second page you do also offer a link to the file just in case something goes wrong or the visitors browser cannot handle imbedded meta redirects, BUT you ALSO add this meta tag to the header section of your (the second) page:
<meta http-equiv=refresh content="3; url=wallies.zip">.

So it's not magic, just a different process.

"MIME"... eh ?
Your computer system and various programs installed over it "associate" certain file name extensions with particular programs. To simplify, obviously your browser(s) at least has ".htm" and ".html" files associated with it. MS Excel will be associated with file extensions of ".csv" and ".xls" amongst other generic and external file name extensions.

Those extensions when recognised, even by double clicking file names in folders, will automatically open the "associated" program.

ALSO your computer system will have separate info describing what to do with those files, and many other file types most of which will not even have an associated program on your computer.

Well, a web server is also equipped with lists of common and not so common file extensions AND when a request is received by a web server to return a specific file the server FIRST sends an HTTP HEADER which also contains a "MIME" directive...

• ".html" will return [ type="text/html" ] in the header.
• A .gif image file will return [ type="image/gif ].
• A ".txt" file will return [ type="text/plain" ].

Many MIME directives are not recognisable to most of us and if you ever come across a list of them one day do not be concerned; i.e. don't wonder where all those associated programs are ?

Therefore the browser recognises say a ".csv" as a file not associated with itself and opens a dialogue box asking you to either "open" the file as it is returned in an associated program on your PC, OR download as a file in to a folder of choice on your computer.

Back to the meta tag:
In place of something like
<meta http-equiv=refresh content="0; url=http://www.your.dom/some.html">
you place
<meta http-equiv=refresh content="3; url=wallies.zip">

The browser is not interested in ".zip" files. So instead of opening yet another web page after the (sample) 3 seconds the browser opens the "open/save" dialogue box for you asking you to do something with the file.

That's it. Simple.

Doh ! Not so simple - there's always a catch.

Anyone can look at your html code and discover the URL to your download file(s) or copy the shortcut via their browser if it is just a simple hyperlink.

So what ?
Well millions of morons place the same links ON THEIR web sites which you may not mind (even to others images believe it or not). BUT even if you don't mind others getting the file via some other website, YOU PAY for the extra bandwidth used by all the downloads accessed by the links on other sites... not the other webmaster - not so good. It's still your sites server sending the files.

Redirects via CGI
If your hosted website comes with allowed use of and installation of CGI programs (i.e. perl scripts)
then the only way to avoid "file link pirating" other than by complex CGI down-load program processes is to use a "simple" CGI program which is called in place of the actual file name (the link is changed).

1) The actual file URL is hidden from most people, the CGI program organises the "redirected" URL,
2) The simple CGI program can also be used to "click count" usage,
3) Selected links, any links, can be forced to ONLY BE accessible (work) from pages ACTUALLY ON your web site - no remote copies or manually entered browser address bars etc.
4) same can be applied to server-side jvascripts and .css style sheets.

Food for thought aye ?

This page is not to promote it, but I was the first to make publicly available such a simple CGI program years ago. It is called "LnkinLite" and can be accessed via my "Scripts" pages (or you can request we "professionally" install it for you for a nominal fee). LnkinLite can even be used to click-count email imbedded links too.

And if you don't have a decent real web site with CGI and many other goodies for future expansion and one day you want to get your own domain name, as of June/July 2003 I will be offering full featured Web Site Hosting for about AUD$16/month - around only 60%-65% of that in US$... and we will be installing my free-to-use perl CGI scripts with each account.

< back

Over 120 pages: All major topics divided into Classrooms
Free Backgrounds & Buttons! DTP and HTML "My First Page" HTML lessons
Tutorial Text Search Perl CGI Scripts Typography & Layout
4 pages of Links Visitors Book Perl Scripts Forum n/a
Free Links page Feedback Form Q/A contact Forum

pages Designed & Published - Ron F Woolley
e-mail 1997 '98. Last Revised:  Friday, 31 October 2003 22:04