View Full Version : Download link question
shakespeare
Feb 21, 2003, 12:40 PM
In HTML, how do you write a link to a file so that the browser will download the file to disk, rather than try to open it itself?
yzedf
Feb 21, 2003, 01:00 PM
that is a browser setting.
that is why there is right-click or ctrl-click...
rainman::|:|
Feb 21, 2003, 01:01 PM
it's not how you link a file, it's how the browser on the other end is set to handle it. For instance, Safari knows that files ending in ".dmg" aren't viewable in a Safari window, so it downloads it instead. Most browsers have a control panel that lets you change settings for various file extensions and MIME types.
pnw
shakespeare
Feb 21, 2003, 01:03 PM
Yes, I realize that, but I'm thinking here of a special page for downloads, such as the "file sharing" pages on .Mac where you can access members' iDisk public folders. On those pages you can just click a little "download" arrow and the file starts downloading right away.
I'd love to have people on my website just click an icon and have the file download automatically - and I'd rather not have to teach them how to configure their browsers or right-click &c. Is there any way?
ibookin'
Feb 21, 2003, 01:06 PM
Not sure if there is a way to do that in HTML, but I think you can configure your webserver (Apache in Mac OS X, etc.) to not recognize file types, which would make the browser download the file by default. I'm not sure if this would work, though...
You need to have access to your webserver config to do this.
shakespeare
Feb 21, 2003, 01:27 PM
Thanks for the help - does anyone have any idea how the File Sharing pages on .Mac pull this off?
yzedf
Feb 21, 2003, 10:32 PM
Originally posted by shakespeare
Thanks for the help - does anyone have any idea how the File Sharing pages on .Mac pull this off?
read the page source...? if it isn't obvious then it must be serverside.
shakespeare
Feb 21, 2003, 11:19 PM
Mm, I did read the page source - on a Mac, the page links to a .sit file, which automatically downloads (rather than opens in the browser); and on Windows, it links to a mysteriously named file 'shakespeare.pdf-link.pdf' or 'shakespeare.html-link.html' &c. The part before the hyphen is the real filename, and what follows, just a 'link'.
So yes, I suppose, that must be serverside. Damn, I guess I'll have to wait a while before I figure it out.
vBulletin® v3.6.10, Copyright ©2000-2009, Jelsoft Enterprises Ltd.