Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP get_file_contents()函数超时_Php - Fatal编程技术网

PHP get_file_contents()函数超时

PHP get_file_contents()函数超时,php,Php,我有一个函数,它将sql转储数据放入变量中。大约是20MB。我需要读取数据并通过api进行传输 public function fileGenerate() { $dumpData = $myController->generate(); $opts = array( 'http'=>array( 'method'=>"GET",

我有一个函数,它将sql转储数据放入变量中。大约是20MB。我需要读取数据并通过api进行传输

public function fileGenerate()
    {
            $dumpData = $myController->generate();
            $opts = array(
                'http'=>array(
                    'method'=>"GET",
                    'header'=>"Content-Transfer-Encoding: binary"
                )
            );

            $context = stream_context_create($opts);

            $fileData = file_get_contents($dumpData, false, $context);
            echo $fileData;
                   }
      }

代码有时工作,有时给出超时错误。另外,我的问题是如何通过curl从另一台机器读取此数据并将数据保存到文件中?

您可以设置超时:

$opts = [
    'http' => [
        // ...
        'timeout' => 100, // in seconds
    ],
];
$context = stream_context_create($opts);

我放二进制文件的方式还可以吗?如何在另一台机器上创建一个curl函数来将数据保存到文件中?