Firefox downloads mp3 files without extension

I am using the download class that I found here http://www.phpclasses.org/package/3220-PHP-Serve-files-for-download-with-resume-support.html to allow ppl to download mp3 files.

It works great in all browsers except Firefox (in all versions).

When I upload an mp3 file using this class in firefox, it downloads files without the .mp3 extension. What can cause this and how can I fix it?

+4
source share
3 answers

Without any code, I assume you are not sending the file name as an HTTP header:

header("Content-Disposition: attachment; filename=" . $filename); 

You must also send the correct MIME type:

 header("Content-type: audio/mpeg3"); 

EDIT: Nevermind, thought I couldn’t upload the file to the OP link and now I see that I was wrong. The script explicitly uses these methods, just not sure if it is doing it right.

+1
source

It seems that in order for Firefox to save the file with the extension, you must surround the file name with quotes.

 header('Content-Disposition: attachment; filename="'.$file.'"'); 
+8
source

Please check the file name again. If the file download has 1 character, this is a space ("") Example: "template import.xls". Firefox will be a mistake that without an extension in the download. You can replace the function ("," ") to fix this problem with asp.net:

HttpContext.Current.Response.AddHeader ("content-disposition", "attachment; filename =" + reportName.Replace ("," "));

+2
source

Source: https://habr.com/ru/post/1380090/


All Articles