PHP cURL, writing to file

后端 未结 6 1008
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 09:12

I want to try connecting to a remote file and writing the output from there to a local file, this is my function:

function get_remote_file_to_cache()
{

$the         


        
6条回答
  •  无人及你
    2020-12-29 09:56

    You need to explicitly write to the file using fwrite, passing it the file handle you created earlier:

    if ( $httpCode == 404 ) {
        ...
    } else {
        $contents = curl_exec($curl);
        fwrite($fp, $contents);
    }
    
    curl_close($curl);
    fclose($fp);
    

提交回复
热议问题