如何使用curl而不会使我的网站崩溃?

时间:2019-06-02 01:51:22

标签: php curl

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 broser is in infinite loop

有什么方法可以使大尺寸或卷曲的产品不致所有人崩溃?

//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);

例如,在20分钟的循环中,我的整个网站都停止工作,直到循环结束为止, curl也会发生同样的情况,下载3GB或更大的文件时,所有文件都将失去对网站的访问权限

对不起,我正在使用Google翻译。

0 个答案:

没有答案