How to force file download with PHP

后端 未结 11 1537
被撕碎了的回忆
被撕碎了的回忆 2020-11-21 23:13

I want to require a file to be downloaded upon the user visiting a web page with PHP. I think it has something to do with file_get_contents, but am not sure how

11条回答
  •  一生所求
    2020-11-21 23:18

    try this:

    header('Content-type: audio/mp3'); 
    header('Content-disposition: attachment; 
    filename=“'.$trackname'”');                             
    readfile('folder name /'.$trackname);          
    exit();
    

提交回复
热议问题