0

I'm trying to force a download so this is my code:

$file = 'test.m4r'; $mime = 'audio/aac'; header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header('Content-Description: File Transfer'); header("Content-Type: $mime"); header('Content-Length: ' . filesize($file)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); 

The file extension should be .m4r, even though the mime is aac. On some computers it's downloaded as test.m4r, while on other computers, the file has extension of test.m4r.acc. How do I fix this problem?

Thank you!

2 Answers 2

1

You can lie about the mimetype, but besides that there isn't anything you can do. Try:

"application/octet-stream"

This might work, and is the default for unknown filetypes etc.

Sign up to request clarification or add additional context in comments.

Comments

1

try this one

<?php header("Content-Type: application/force-download"); ?> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.