PHP CURL传输文件:55,发送失败:连接已重置

时间:2016-09-06 08:10:40

标签: php curl

我的代码:

$curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'http://site/index.php?1c.upload&filename=' . $filename);
    curl_setopt($curl, CURLOPT_COOKIE, $cookie);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $files); //Array CURLFile
    echo $out = curl_exec($curl);

当我尝试发送文件10Mb时 - 一切正常。 当我尝试发送文件〜200Mb - 我收到错误

  

55,发送失败:连接已重置

  

56,Recv失败:连接已重置

我试着写curl_setopt($curl, CURLOPT_HTTPHEADER, ['Expect:']); 没结果...... 并尝试curl_setopt($curl, CURLOPT_TIMEOUT, 3600); - 同样......

在php.ini中:

max_execution_time = 3600
max_input_time = 3600
upload_max_filesize = 500M
post_max_size = 500M

在php文件中尝试set_time_limit(3600);但不是结果......

返回数组:

[url] => myurl
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 306
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 29.328
[namelookup_time] => 0.016
[connect_time] => 0.031
[pretransfer_time] => 0.031
[size_upload] => 116490450
[size_download] => 0
[speed_download] => 0
[speed_upload] => 3971987
[download_content_length] => -1
[upload_content_length] => 175979724
[starttransfer_time] => 1.045
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => serverIP
[certinfo] => Array
    (
    )

[primary_port] => 80
[local_ip] => 192.168.0.45
[local_port] => 1854

1 个答案:

答案 0 :(得分:0)

问题解决了! 需要更改Nginx配置:

client_max_body_size