SO i have a url of an mp3 file and i need to save it to a specific directory. How is the best way to do this, someone told me curl but is there a copy file of some php command that will make this process easier
NOTE: The destination must include the file name and the directory must exist.
1
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://amanjain.com/path-to-mp3.mp3');
//Create a new file where you want to save
$fp = fopen('filename.mp3', 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
curl_close ($ch);
fclose($fp);
?>
Make sure also you also modify your pages allowed execution time. Most pages only allow 30 seconds, especially if you are doing this over a HTTP page (a webpage). You need to up this to match how long it actually takes to download the file.