PHP curl 上传大文件非常大慢,导致超时,小文件(10M以下)的还可以,请问如何解决啊! 10
functiongethttpcurl($url,$ntarr=null,$userToken=''){session_start();$strCookie="PHPSE...
function gethttpcurl($url, $ntarr = null, $userToken=''){
session_start();
$strCookie = "PHPSESSID=" . $_COOKIE['PHPSESSID'];
session_write_close();
$ch=curl_init();
$header[]='Expect:';
if($userToken){
$header[]='USERTOKEN:'.$userToken;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //强制协议为1.0
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); //强制使用IPV4协议解析域
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, (isset($ntarr['timeout']) && is_numeric($ntarr['timeout']))?$ntarr['timeout']:600);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, $strCookie);
if(is_array($ntarr['postarr'])){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $ntarr['postarr']);
}
$s = curl_exec($ch);
curl_close($ch);
return $s;
}
$data['title'] = $title;
$data['videofile'] = new \CURLFile(UPLOAD_PATH .$file);
$fileinfo = gethttpcurl(URL, array('postarr' =>$data)); 展开
session_start();
$strCookie = "PHPSESSID=" . $_COOKIE['PHPSESSID'];
session_write_close();
$ch=curl_init();
$header[]='Expect:';
if($userToken){
$header[]='USERTOKEN:'.$userToken;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //强制协议为1.0
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); //强制使用IPV4协议解析域
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, (isset($ntarr['timeout']) && is_numeric($ntarr['timeout']))?$ntarr['timeout']:600);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, $strCookie);
if(is_array($ntarr['postarr'])){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $ntarr['postarr']);
}
$s = curl_exec($ch);
curl_close($ch);
return $s;
}
$data['title'] = $title;
$data['videofile'] = new \CURLFile(UPLOAD_PATH .$file);
$fileinfo = gethttpcurl(URL, array('postarr' =>$data)); 展开
展开全部
修改超时限制:
ini_set('max_execution_time','0');
ini_set('max_execution_time','0');
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |