Links that trigger download

They have: 15 posts

Joined: Dec 2007

Hi

I want to know what can I do so that if a link is clicked a pictures promopts for downloading, similarly a PDF and a text file starts downloading upong clicking a link?

Thanx
Max

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

Hi, welcome to TWF.

I believe this is what you need...

<P>Click
<A HREF="javascript:oDownload.startDownload('img.jpg', onDownloadDone)">here</A> to download this
image.

Let me know how it goes.

All the best news here: https://newsbotnet.com

They have: 15 posts

Joined: Dec 2007

Thanx for the prompt help ChildOfEvil, but unfortunately your trick isn't working for me Sad Though I corrected one "o" of "onDownload", but still it didn't work. Here is my complete code with image name/location:

<a href="javascript:onDownload.startDownload('http://www.thebest404s/images/stories/autoxd1.gif', onDownloadDone)"><img src="http://www.thebest404s/images/stories/autoxd1.gif" alt="autoxd1.gif" title="autoxd1.gif" style="margin: 5px; width: 300px; height: 201px" border="0" height="201" width="300" /></a>'

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

Hi, Sorry about that then, I cannot think of another way to do it. I am not sure that browsers like this behaviour anyways.
Like I said, it take about 2 seconds to Zip the file, and it will make visitors happier, as it will compress them, and make them quicker to download.
Plus a lot of people (including myself) are not too happy about downloading a direct file.
This is because they dont have chance to scan the file before they download, you might think of the term: "Risk it for a biscuit". whereas in a zip file, it is contained until the user is satisfied they have done a thourough safety check.
I know you dont intend to upload a virus, but how do your visitors know that, just the other day I gave Microsoft a bolocking for giving me a sh!t load of rubbish for my browser, i scanned it and i found 2 spyware contained inside the zip file.
If they gave me the files unzipped, the virus would have had chance to distribute itself around my pc.

So you understand what I am saying?

All the best news here: https://newsbotnet.com

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

One thing you could do is dedicate a directory to downloading files. Put an .htaccess file in that directory and put in this code:

<Files *.*>
ForceType applicaton/octet-stream
</Files>
'

Then use regular tags to link to the files in that directory.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.