So I want to download a mp3 file from a dynamic link, when I run the script it creates test.mp3 but it's empty.
Code :
$source = 'http://www.youtubeinmp3.com/download/get/?
i=yt6MfhzTljRBZ6AjqSsnb2ih1ZifuMoY&e=69';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_SSLVERSION,0);
$data = curl_exec ($ch);
$error = curl_error($ch);
curl_close ($ch);
$destination = "test.mp3";
$file = fopen($destination, "w+");
fwrite($file, $data);
fclose($file);
There is nothing in the error.log
EDIT
If I add :curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
It downloads the source of the page (HTML) but not the mp3 file.
Because You are not downloading anything. Check output of your $data = curl_exec ($ch);
. It must be empty