PHP Download MP3 File by URL

PHP Download MP3 File by URL

It will save files on web server then use php header for prompting to download file.

CURL will not work efficiently for big files i.e. MP3, ZIP, MP4 etc.

3. file_get_contents()
This will consume too much memory on server. It can first read remote URL then save and download.

4. Content-type: application/x-file-to-save


if(isset($_REQUEST['inputurl']) && $_REQUEST['inputurl']!="") {

$file = $_REQUEST['inputurl']; 

header("Content-type: application/x-file-to-save"); 
header("Content-Disposition: attachment; filename=".basename($file)); 



<form name="from" method="post" action="">
<input name="inputurl" type="text" id="inputurl"  value="" />
<input type="submit" name="Button1" value="Get File" id="Button1" />

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch