Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

I am trying to download mp3 file from path using php, but instead of downloading its displaying some weird content on page

<?php

$fileName = $_GET['file'];
$path = '/directory/contains/mp3/';
$file = $path.$fileName;

if (!file_exists($file)) {
    http_response_code(404);
    die();
}

header("Cache-Control: private");
header("Content-type: audio/mpeg3");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=".$fileName);
//So the browser can display the download progress
header("Content-Length: ".filesize($file));

readfile($file);
?>

The output is like

ID39TPE1SoundHelixTDRC2009TCONElectronic?????^D?a@k??iC????? l<"f?zn?4(.?tN9?q??]??n?????????>K?l?<?? !?@? H?q?z ?????w9?????????>|??>'?(???J?I0e ???bzb?a?d9???Ns??M??? B)?4?@?C?'??>.???tDDB8/??Z%rШp3G?C?|N ??[???s?]?v?????> =hD1*?3?1??3??#?5???r?Q ???L??*?g?R(t??6Wo???mO"?? ? ???4??_??????"?9?sB|?N ????????t!???+q??x?b?? #??~?????@ %?F?ObsF?+qe???????"?D??aR?j?0?a?.???'? ?|????z???9??????~?M"?? ?M?e}k???z?d???4"?O????@???q?+??p?O???????? e1[?0???????p1??????~?D??IWBx/qx?J?Lcy@dq? 'G???"?6??$ebT?it???.?>?u???"QY?Zrs????T??a"??R???????"5Pa???Q??????X ?>?lhd!?h?????"????~??????D?a?+Bh?Q^?;???Z??Pa??FI???H??M?-??B?6?];????E??]~?????VD???9???y?U?0?M?)U????Qbg??0??C?(????????,?>?lhd!?.?3?? EE?/@ $?o04??<???Mk??t???n3 ???fX?a?= ??:??R{J}??F/)O???F+?F?? ?????>????? ?aW??F?d?a?"'?!!????)?bh?Z???#wU??}??"?f?x?????{w??tJ?%)???????????a?L/@ $?o04??<???Mk??t???n3 ?F+?F?? ?????>????}#@#0??>??"??d???Ha,o7 E?c?4B-J?T??????>??h?t????????L:%r??y<?9??????vd????J??)????]?7???R?q??D????櫔????LS??ep;?!??????li8?#??KY&"w?fCt?79STj??s?kV?????_^????z?kR???;3??????????;ji}!@??J??)????]?7???R?q??D????櫔????LS??ep;?!??????li8?(G??(?&LD?f?4??n?r???}??:?Y[!ν?????f??jQ??W??fe[?U??[?gs?8???a?????>z@?i?Z ?As$??T?a?!p??L?d???????W?F????i??R_OaTd?[??),??U???v9]?=y;?? 8?%9IB?r?T?ǔn?_?3?_?c?? k?_?x@?H?j? .-Y?0??,0?)???7 g ?R5)?ilHfF?&?7??d?7n??,?"????&c??????l??X???wdy?33?r???z??????????????9???]???????????L'2z??Q??l6'?? a?Y???|N7??}?ǚP?U?8?3<ě??3?(o'2???I????Q9?o??{??f??L???U?{?*~??}???%?.?J?????>? ???5?3??IGA??1??q<?0??????Q??l6'?? a?Y???|N7??}?ǚP?U?8?3<ě??3?(o'2???I????Q9?o??{??f??L????]?8????????K?]$?7W?}4+??jg??? ??b)?c??y?a?????$ w? ?l!???6O??5?"?Vo?;5|V?fr &peI????????gU?=????Q?}Ll<??=???????jV???[???E??ZO@?5?L~?x#?BU ??|


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...