Forums

file_get_contents failing due to server config (use curl instead) (2 posts)

  1. angrycamel
    Member
    Posted 4 years ago #

    If you are getting a message saying that downloading the file failed because of server configuration, then comment out the following line:

    $file = file_get_contents($url);

    Above it, paste the following code:

    // Download file
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_HEADER, 0);  // ignore any headers
      ob_start();  // use output buffering so the contents don't get sent directly to the browser
      curl_exec($curl);  // get the file
      curl_close($curl);
      $file = ob_get_contents();  // save the contents of the file into $file
      ob_end_clean();  // turn output buffering back off
  2. hschaefer
    Member
    Posted 4 years ago #

    Oops, I seem to have missed that call to file_get_contents() when rewriting the tool to be cURL compatible.

    What I did (for those people without curl support compiled into their php binary) was exchanging the calls to fopen with a process pointer to the commandline cURL tool. I will try to do this for file_get_contents, too. Is there anyone with fopen_wrappers problems who would like to test the fixed version before it is published?

Topic Closed

This topic has been closed to new replies.

About this Topic