Skip to content

Instantly share code, notes, and snippets.

@OkoyaUsman
Created September 29, 2022 21:49
Show Gist options
  • Save OkoyaUsman/4e9a9cce3f0e5a254fbddbc9dbbc8e70 to your computer and use it in GitHub Desktop.
Save OkoyaUsman/4e9a9cce3f0e5a254fbddbc9dbbc8e70 to your computer and use it in GitHub Desktop.
Stream/Download video files from remote location to users without memory overload
<?php
$url = "";
$useragent = "";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 222222);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header){
header($header);
return strlen($header);
});
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($curl, $body){
echo $body;
return strlen($body);
});
$response = curl_exec($ch);
curl_close($ch);
exit;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment