/    Sign up×
Community /Pin to ProfileBookmark

Download objects to desktop

I am creating a personal web site and want to offer vistors the chance to download some of the music I have written. Currently I have a simple anchor tag that points to a mp3 object containing the sample. When clicked, the music is downloaded and starts playing (using whichever music software is installed). However, I want the visitor to have the chance to save the file to disk, which is not happening.

How do I get a download dialogue window to appear, prompting the user to either save the file to disk or to open it directly?

I would like this technique to also work with other objects such as Word documents or Excel spreadsheets – again, giving the user the chance to save to his hard disk rather than opening in the browser window…

to post a comment
HTML

7 Comments(s)

Copy linkTweet thisAlerts:
@Robert_WellockSep 04.2003 — It depends upon the user-agent that the liveware has however, if you are using Apache Server you could use .htaccess and octet-stream to force downloads.

For example within the .htaccess file you'ld write:

AddType application/octet-stream .doc
AddType application/octet-stream .xls
Copy linkTweet thisAlerts:
@jimbob2812authorSep 04.2003 — Wow, thanks for the quick reply. The only thing is, I don't think I understand any of it! However, it seems like you are asking me to configure things I do not have any control over.

The site is on freespace, so I do not have access to any of the server side configuration. I have a mp3 object sitting on the net in a directory and a simple anchor tag linking to it. I am trying force this link to download and save the object, but from within my HTML or how the object is uploaded to the net, as I do not know how to configure any of the other things...
Copy linkTweet thisAlerts:
@DaveSWSep 04.2003 — do you have php?
Copy linkTweet thisAlerts:
@jimbob2812authorSep 04.2003 — yes - and I have dabbled a little in this language...
Copy linkTweet thisAlerts:
@DaveSWSep 04.2003 — In that case here's one of pyro's examples: http://www.infinitypages.com/research/download.htm

ps - if you get stuck, ask pyro not me!!
Copy linkTweet thisAlerts:
@jimbob2812authorSep 04.2003 — Wow, complicated but brilliant. Thanks a lot DaveSW for the tip to Pryo's code, and his solution backs up what Robert said in his post...will give it a go, but seems exactly what I was looking for....cheers all...
Copy linkTweet thisAlerts:
@GavinPearceSep 07.2003 — just to explain the .htaccess a bit.

Basically you create a file a txt file. Call it sumthing like a.htaccess (because windows tells you that you have to have a file name). In that file but the text
<i>
</i>AddType application/octet-stream .mp3


then upload the file. When it's on the server rename it .htaccess make sure there is nothing before the '.'

Just .htaccess.


.htaccess is a settings file, as you have PHP it will probally work.
×

Success!

Help @jimbob2812 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...