Guest User

Untitled

a guest
Jan 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. if (preg_match("/http/",$url_files)){
  2. $ch = curl_init($url_files);
  3. curl_setopt($ch, CURLOPT_HEADER, 0);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  5. curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
  6. $out = curl_exec($ch);
  7. $image_sv = 'путь_куда_вы_сохраняете_картинку'.$nm.'.jpg';
  8. $img_sc = file_put_contents($image_sv, $out);
  9. curl_close($ch);
  10. }
  11.  
  12. use MCurlClient;
  13.  
  14. $urls = array(
  15. 'ht tp://cs1-38v4.vk-cdn.net/p13/cdfeaeaf00705d.mp3',
  16. 'ht tp://cs1-32v4.vk-cdn.net/p2/5c0972b283ee17.mp3',
  17. );
  18. $save_path = '/tmp';
  19.  
  20. $client = new Client();
  21.  
  22. do {
  23. while ($client->has()) {
  24. $result = $client->next();
  25. // Пересохраняем рисунок с ошибкой
  26. if ($result->hasError()) {
  27. $urls[] = $result->options[CURLOPT_URL];
  28. }
  29. }
  30.  
  31. foreach($urls as $url) {
  32. $file = $save_path . '/'. basename($url);
  33. $client->add([
  34. CURLOPT_URL => $url,
  35. CURLOPT_FILE => fopen($file, 'w'),
  36. ]);
  37. }
  38. $urls = [];
  39.  
  40. } while($client->run() || $client->has());
Add Comment
Please, Sign In to add comment