By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,092 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,092 IT Pros & Developers. It's quick & easy.

How to force a download dialog box

P: n/a
How do I force a browser to download a file instead of displaying it? In
other words I have a page with MP3 and WMA files on it and I would like for
the visitor to download the file instead of play it without having to
right-click and save.

How can I force the browser to pop up the "save file as" dialog box instead
of playing it? I know that I can encapsulate it in a zip file which will
download and open WinZip.

Thanks

Kevin

--
Kevin Muenzler, WB5RUE
2914'52"N 9814'50"W
Eagle Creek Observatory
http://www.eaglecreekobservatory.org
Eagles may soar, but weasels don't get sucked into jet engines.

replace bitbucket by kevin in my email to respond.

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Kevin Muenzler, WB5RUE wrote:
How do I force a browser to download a file instead of displaying it? In
other words I have a page with MP3 and WMA files on it and I would like for
the visitor to download the file instead of play it without having to
right-click and save.
You don't "force" anything on the web, you suggest:

<a href="URLToMP3File.mp3">Right Click and choose Save As</a>
How can I force the browser to pop up the "save file as" dialog box instead
of playing it? I know that I can encapsulate it in a zip file which will
download and open WinZip.


It does? Wow. I don't even have Winzip on my computer. If you can pull
that one off, you will be a lot smarter than anybody I know. Again, you
don't force anything, and definitely not a download window.

Or give it your own made up extension that the browser won't have
anything associated with.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2

P: n/a
Kevin Muenzler, WB5RUE wrote:
How do I force a browser to download a file instead of displaying it?


Not by using client side scripting. You can try to do that using server
side scripting by sending

Content-Type: application/octet-stream\r\n
Content-Disposition: attachment; filename=[Your file name here]\r\n\r\n
[Your file content here]

Most current browsers will rather download than display the file then.

ciao, dhgm
Jul 23 '05 #3

P: n/a
You know Randy,
I hope you don't run a helpdesk service. With a bedside manner like that
you wouldn't last long. ;) If you don't have Winzip installed XP, and
probably 2000, will download the file to the Temp area and launch Windows
Explorer to display the contents. If you don't have a Wintel machine then
all bets are off.

As I'm sure you know...If the link is a known mime type <place browser name
here> will either attempt to display it or launch the associated program
after downloading it to the Temporary Internet Files area. If it's an
application mime type a "Save As" dialog box will be displayed. If it's not
a known mime type (file.xyz) the browser will attempt to figure out how to
run it or display it.

I have two file types, MP3 and WMA both are "known" mime types to WinX
operating systems that are reasonably updated. If a person clicks on a link
the file is downloaded to Temporary Internet Files and then played in the
associated application. Media Player 9+ attempts to play the file as it's
downloading. If the bit-rate of the file is higher than the download speed
there's lots of pausing. This is annoying to some people. I would like to
make it as simple as possible for the user to download the file without any
fancy right-click/save target as. Especially since not every browser uses
those terms. I would like for the user to just be able to click on the link
to the file and have the browser ask him where he wants to save it. It
can't be THAT difficult, eh?
--
Kevin Muenzler, WB5RUE
2914'52"N 9814'50"W
Eagle Creek Observatory
http://www.eaglecreekobservatory.org
Eagles may soar, but weasels don't get sucked into jet engines.

"Randy Webb" <Hi************@aol.com> wrote in message
news:-M********************@comcast.com...
Kevin Muenzler, WB5RUE wrote:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of play it without having to
right-click and save.


You don't "force" anything on the web, you suggest:

<a href="URLToMP3File.mp3">Right Click and choose Save As</a>
How can I force the browser to pop up the "save file as" dialog box instead of playing it? I know that I can encapsulate it in a zip file which will download and open WinZip.


It does? Wow. I don't even have Winzip on my computer. If you can pull
that one off, you will be a lot smarter than anybody I know. Again, you
don't force anything, and definitely not a download window.

Or give it your own made up extension that the browser won't have
anything associated with.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 23 '05 #4

P: n/a
Kevin Muenzler, WB5RUE wrote:
You know Randy,
I hope you don't run a helpdesk service. With a bedside manner like that
you wouldn't last long. ;) If you don't have Winzip installed XP, and
probably 2000, will download the file to the Temp area and launch Windows
Explorer to display the contents. If you don't have a Wintel machine then
all bets are off.
I have WinXP SP2, no zip program, and it does nothing after clicking a
..zip file link other than asking me what program I might want to
associate with it. As for the helpdesk, you and I both are glad I don't.

But when I do download a .zip file, IE does nothing because I do not do
most of my browsing with IE.
As I'm sure you know...If the link is a known mime type <place browser name
here> will either attempt to display it or launch the associated program
after downloading it to the Temporary Internet Files area. If it's an
application mime type a "Save As" dialog box will be displayed. If it's not
a known mime type (file.xyz) the browser will attempt to figure out how to
run it or display it.
And whether the browser tries to run it or display it is directly
related to two things:

1) The MIME type, which the site author has some control over (depending
on server access).
2) User settings. Of which the site author has *no* control over.
I have two file types, MP3 and WMA both are "known" mime types to WinX
operating systems that are reasonably updated.
REally? I just updated WinXP SP2 not a week ago and it still doesn't
know what an MP3 is. But that is directly related to me telling it not
to know what it is.
If a person clicks on a link the file is downloaded to Temporary Internet
Files and then played in the associated application.
That depends directly on the browser involved, how the file is
downloaded, and user settings.
Media Player 9+ attempts to play the file as it's downloading.
That I honestly can't say anything about, never use MP.
If the bit-rate of the file is higher than the download speed there's
lots of pausing. This is annoying to some people.
Yes, it can be. Stream it and the problem is solved and let the user's
browser and settings handle it.
I would like to make it as simple as possible for the user to download
the file without any fancy right-click/save target as.
That is as simple as it gets though. How would you propose to have a
script force a download dialog if scripting is disabled?
Especially since not every browser uses those terms.
I would like for the user to just be able to click on
the link to the file and have the browser ask him where
he wants to save it.
Make it a .zip file or some unknown MIME type and that will occur. I
know of no browser that when presented with an unknown (to the browser)
MIME type will attempt to open the file.
It can't be THAT difficult, eh?


I gave you the simplest solution, it just seems that it was a solution
that you didn't want to hear. Sometimes the simplest way is the best way.

Please read this groups FAQ, via signature below, and it will enlighten
you to a lot of good information.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.