473,545 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing download dialog

15 New Member
I'm using this script to force browser's download dialog :
Expand|Select|Wrap|Line Numbers
  1. $fp=fopen('Survivor - Eye of tiger.mp3','r');
  2. $name=basename("Survivor - Eye of tiger.mp3");
  3. $size=filesize('Survivor - Eye of tiger.mp3');
  4. header('Content-Type: audio/mpeg');
  5. header('Content-Length:$size');
  6. header("Content-Disposition: attachment;filename= $name");
  7. fpassthru($fp);
  8. fclose($fp);
  9.  
The file is downloaded but it has no extension when I use Mozzila firefox.It doesn't happen with Opera and IE.Anyone know why?
Nov 9 '07 #1
1 1263
Atli
5,058 Recognized Expert Expert
Hi.

That would depend on the browser you are using.

My tests on this subject so far indicate that:
  • IE is the most adapt at correctly interpreting headers such as these, usually finding the correct file extension.
  • FireFox and Opera usually find the correct extension, but are a little more selective than IE on the header data. You may have to play with the Content-type to find the right one with these two.
  • Safari is completely useless in this respect. It completely ignores the headers and downloads all files as the original .php file name.

You could try changing the Content-type to 'Mp3', or add a .mp3 extension to the file name in the 'Content-Disposition' header.
Nov 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1921
by: lmb | last post by:
Hi all, Does anyone know how to force the download of a text file ? In my script, I tried : header("location: my_text_file.txt") ; ....and of course, I get my text in my browser as I wanted a download dialog box to appear. Any help, Many thanks in advance,
6
3076
by: JCO | last post by:
Does anybody have a Download Dialog written in JavaScripts? This is for a website. I've seen it done before.... where you click on what you want and the dialog comes up asking you if you want to save it. From what I can tell, the name of the file is passed as a parameter of the JavaScript. Below is an example of what somebody (who I don't...
0
916
by: Mike P | last post by:
Hi, I am trying to implement on an ASP.NET page that when a user clicks on a file link, it forces the Save/Open box in the browser. I have managed to do this (with a little help from this newsgroup) but now when the user clicks open, the dialog pops up again and only after clicking open again, the file opens in whatever application is...
4
1434
by: ACaunter | last post by:
Hi, when the download dialog box opens and i click save or open or cancel.. everything works fine.. but then it's stuck in memory or something, because nomatter what button, listbox, combobox, etc.. i click on next.. that download dialog box keeps coming up... why is that??? -- AdamPC@hotmail.com
4
3391
by: randmCP | last post by:
Hi and thanks in advanced for you help. I am working on a file-distribution asp.net application. Users click on a custom grid column to download files stored on a SQL DB. The client does not want to open the file in the browser, so how can I either: 1. Display the Save Target as dialog box to download the a file when the file is in memory...
2
1650
by: Ken Varn | last post by:
I have an ASP.NET page that incorporates the following code on a button press. private void DownloadTag_Command(object sender, CommandEventArgs e) { FileStream fs; String Filename; Filename = MapPath(e.CommandArgument as string); // Name of file is passed in cmd arg.
4
1522
by: teeBull | last post by:
Hi all, We'd like to take advantage of code we already have for transforming XML into HTML (using XSLT) for our users to save the HTML as an MS Word document locally. I've dug around and found the following code to include in the code behind: Response.ContentType = "application/vnd.ms-word" Response.AddHeader("Content-Disposition",...
1
1742
by: sunita | last post by:
Hiii I open a file download dialog from a modal dialog...From the file download dialog i can either save or open the file.. Is there a way i can let the modal dialog that opens the file download dialog know whether the user has clicked on the open button or the save button of the file download dialog??
1
47376
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or...
0
7486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7676
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7932
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6001
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.