php force download extension

前端 未结 2 702
臣服心动
臣服心动 2021-01-27 10:28

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\");          


        
相关标签:
2条回答
  • 2021-01-27 10:57

    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.

    0 讨论(0)
  • 2021-01-27 11:06

    try this one

    <?php header("Content-Type: application/force-download"); ?>
    
    0 讨论(0)
提交回复
热议问题