472,792 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,792 software developers and data experts.

How to force a download dialog box

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
29º14'52"N 98º14'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
4 21842
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
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
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
29º14'52"N 98º14'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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Navin | last post by:
hi, guys i am using the following code to force a file download dialog in asp Response.ContentType = "application/vnd.ms-excel" response.AddHeader "content-disposition","attachment; filename="...
1
by: Navin | last post by:
hi, guys i am using the following code to force a file download dialog in asp Response.ContentType = "application/vnd.ms-excel" response.AddHeader "content-disposition","attachment; filename="...
2
by: E Stafford | last post by:
I am creating a form app that uses a webBrowser control and allows users to interact with a web hosted application. Users can query the web app and generate a CSV file that they should be able to...
0
by: PJS | last post by:
Thanks in advance. I have a site which generates a user specific XML document. The user then selects "Save to PC" which then forces the browser to show the "save/download" dialog box. The code...
1
by: greg | last post by:
Hi I have a link on a page that points to a file inside the site that I want to be downloaded loke in page_load I write linkFile.NavigateUrl = Request.ApplicationPath + "/somepath/file.iif";...
5
by: gaubo79 | last post by:
I am wishing to force the Open|Save dialog box for a PDF and Excel file. I am using the following code: Response.Clear(); Response.ContentType = "application/octet-stream";...
0
by: Mustafa Rabie | last post by:
Hi All, I am writing an ASP.NET 2.0 Web Application that users can buy and download pictures, songs, etc. I have a page that servers as the download page that fetches the file to be downloaded...
0
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL...
1
by: JP SIngh | last post by:
Hi All We have a page which we want to allow our users to download files. Can someone point to peice of code that we can use to force the download as opposed to opening the files in the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.