Advertisement
Guest User

Untitled

a guest
Nov 21st, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. function download($url,$name,$hash){
  2. $ch = curl_init($url);
  3. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  4. $data = curl_exec($ch);
  5. curl_close($ch);
  6. $mh = curl_multi_init();
  7. $active = null;
  8. curl_multi_add_handle($mh,$ch);
  9. do {
  10. $mrc = curl_multi_exec($mh, $active);
  11. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  12. while ($active && $mrc == CURLM_OK) {
  13. if (curl_multi_select($mh) != -1) {
  14. do {
  15. $mrc = curl_multi_exec($mh, $active);
  16. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  17. }
  18. header('Content-Description: File Transfer');
  19. header("Content-Disposition: attachment; filename=".$name);
  20. readfile(curl_multi_getcontent($ch));
  21. ob_clean();
  22. flush();
  23. }
  24. curl_multi_remove_handle($mh, $ch);
  25. curl_multi_close($mh);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement