Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function download($url,$name,$hash){
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- $data = curl_exec($ch);
- curl_close($ch);
- $mh = curl_multi_init();
- $active = null;
- curl_multi_add_handle($mh,$ch);
- do {
- $mrc = curl_multi_exec($mh, $active);
- } while ($mrc == CURLM_CALL_MULTI_PERFORM);
- while ($active && $mrc == CURLM_OK) {
- if (curl_multi_select($mh) != -1) {
- do {
- $mrc = curl_multi_exec($mh, $active);
- } while ($mrc == CURLM_CALL_MULTI_PERFORM);
- }
- header('Content-Description: File Transfer');
- header("Content-Disposition: attachment; filename=".$name);
- readfile(curl_multi_getcontent($ch));
- ob_clean();
- flush();
- }
- curl_multi_remove_handle($mh, $ch);
- curl_multi_close($mh);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement