Php 旋涡未按预期工作

Php 旋涡未按预期工作,php,curl,Php,Curl,在此代码中: $url = 'http://example.com/someLARGE.file'; $path = 'test.txt'; $fp = fopen($path, 'w+'); $curl = curl_init(); //curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FILE, $fp); curl_setopt ($cu

在此代码中:

$url  = 'http://example.com/someLARGE.file';
    $path = 'test.txt';

    $fp = fopen($path, 'w+');

    $curl = curl_init();

    //curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt ($curl, CURLOPT_URL, $url);

    curl_exec($curl);

    curl_close($curl);
    fclose($fp);
输出将写入浏览器,而不是服务器上的文件:(

尝试使用

file\u put\u contents
与调用
fopen()
fwrite()
fclose()
连续地将数据写入文件。

in $fp=fopen($path,'w+');
我没有创建/写入该文件的权限。

只有在取消对CURLOPT_RETURNTRANSFER行的注释时,此操作才有效。您能否确认您可以写入$path?curl并不总是报告无效文件的错误handles@jrowley,你能发布一个问题让我接受吗?如果你找到了解决方案,自己写一个答案,然后回答n接受它,
$result = curl_exec($curl);

file_put_contents($file, $result,FILE_APPEND | LOCK_EX);