Reputation: 1
I want to force a download.. In IE I get an error but there are no problems in FF
header("Content-Type: application/force-download\n");
header("Content-Disposition: attachment; filename=test.txt");
echo 'test file';
Upvotes: 0
Views: 1562
Reputation: 14500
This might help you , it works for me
header('Content-Type: application/force-download');
header("Content-disposition: attachment; filename=$filename");
flush();
readfile($filename);
exit;
you can add other headers if desired :)
Upvotes: 0
Reputation: 132061
I just googled about your curious application/force-download
mime type. I dont know, who did "invented" this, but it seems, that it just dont exists. See http://mimeapplication.org/force-download.html
This means, the IE probably dont like it. Use application/octet-stream
instead. As far as I remember firefox opens a download dialog for every mime-type, that is either registered with "show download dialog", or it simply doesnt know. In this case FF probably doesnt know the type.
Upvotes: 5