473,320 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Forcing download dialog

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 1254
Atli
5,058 Expert 4TB
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
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...
6
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...
0
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...
4
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,...
4
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...
2
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...
4
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...
1
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.