Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firefox downloads mp3 files without an extension

I am using a Download Class which i found here http://www.phpclasses.org/package/3220-PHP-Serve-files-for-download-with-resume-support.html to let ppl download mp3 files.

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

When i download an mp3 file using this class in firefox, it downloads files without .mp3 extension. what may cause this and how can i fix it ?

like image 534
Utku Dalmaz Avatar asked Dec 22 '22 06:12

Utku Dalmaz


2 Answers

It seems that for Firefox to save the file with an extension you must surround the filename with quotes.

header('Content-Disposition: attachment; filename="'.$file.'"');
like image 156
CTS_AE Avatar answered Dec 24 '22 02:12

CTS_AE


Please check again filename. If file download have 1 character is spacebar (" ") Example: "template import.xls". Firefox will be error that without extension in download. You can function replace(" ", "") to fix this issue with asp.net:

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

like image 26
ngocld Avatar answered Dec 24 '22 00:12

ngocld