I've been work for file download at remote server by using fopen function but i get the error :
Warning: fopen(/a/b/song.mp3) [function.fopen]: failed to open stream: No such file or directory
Warning: curl_setopt(): supplied argument is not a valid File-Handle resource
Warning: fclose(): supplied argument is not a valid stream resource
My code as per below :
Expand|Select|Wrap|Line Numbers
- $url_128 = "/a/b/song.mp3";
- $url = 'http://a.com:8080'.$url_128;
- $path = $url_128;
- $fp = fopen($path, 'w');
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_FILE, $fp);
- $data = curl_exec($ch);
- curl_close($ch);
- fclose($fp);