0

I want to create a site like this https://transferring-videos.com/, I'm trying to upload a video or read the content of a website but when curl is running or when a loop is running all my site hangs, nobody get access, the browser is in infinite loop

Is there any way to loop a large or curl without crashing my site for everyone?

//This is my code to download 

$url = "http://test.com/video.mp4";
$file       = base64_encode(substr($url, strrpos($url, "/")+1));
$dir            = ROOT_DIR.'/uploads/';
$dir_file       = $dir.$file;


    $ch         = curl_init($url);
    $filename   = $dir.$file;
    $fp         = @fopen($filename, "w");
    curl_setopt($ch, CURLOPT_TIMEOUT, 99999999999);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $content = curl_exec($ch);
    curl_close($ch);
    fclose($fp);

In a 20 minute loop for example my whole site stops working until the loop finishes. The same happens with curl, when downloading a file of 3Gb or more all lose access to the site

Sorry for my bad English, I'm using a google translate.

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
  • Run it via `php-cli` instead of the web version, never put that kind of load on the web version, you'll literally freeze the rest of the website for anyone trying to access it – zanderwar Jun 02 '19 at 02:01
  • Does async curl help? https://stackoverflow.com/questions/36171222/async-curl-request-in-php – JasonB Jun 02 '19 at 07:54

0 Answers0