curl文件传输错误PHP

时间:2013-05-26 19:31:02

标签: php curl file-transfer

我可以成功从youtube传输高清视频。因为youtube让我高速下载高清视频。但SD或HQ视频我无法传输到我的服务器,因为youtube为SD或HQ视频提供低速。当我想传输SD或HQ视频时,我得到
'504网关超时
网关未收到上游服务器或应用程序的及时响应。
如果youtube给我高速传输视频我不会得到这个错误。我该如何解决?我的代码是:

$url = $_POST['url'];
$url = base64_decode($url);
$file = uniqid();
$file2 = $file;
$extension = $_POST['extension'];
$extension = base64_decode($extension);
set_time_limit(0);
$fp = fopen (dirname(__FILE__) . "/downloads/$file.$extension", 'w+');
    $ch = curl_init($url);

curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp); // write curl response to file
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch); // get curl response
curl_close($ch);
fclose($fp);

0 个答案:

没有答案