title: cURL not properly downloading images
body: <p>I'm having a problem with cURL.  I am downloading images and saving them to a folder.  The file that cURL creates has the right filesize, which makes me think that the headers are being read properly.  But, when I open the file up in my browser or in any picture-viewing application, only a tiny bit at the top appears to actually have been written.  My code:</p>
  
  <pre><code>function _vancore_curl_savefile($url) {
    $url = str_replace("\"", "", $url);
    $basename = basename($url);
    $basename = str_replace("%20", "_", $basename);
    $var = file_directory_path() . "/van/" . $basename;
    $uvar = "files/van/" . $basename;
    $handle = fopen($var, "w");
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_FILE, $handle);
    $result = curl_exec($curl);
    $result2 = $result;
    curl_close($curl);
    fclose($handle);
    return $uvar;
  }
  </code></pre>
  
  <p><code>file_directory_path()</code> is a Drupal function (this function is part of a Drupal module and called for each file that needs to be downloaded) that returns the path to the Drupal file download directory.  I have confirmed through various tests that:</p>
  
  <p>a) <code>$url</code> is what it should be<br>
  b) <code>fopen()</code> is opening the right file<br>
  c) <code>curl_exec()</code> is returning <code>true</code> after it is executed</p>
  
  <p>I am very confused about what is going wrong here.  Anyone have any thoughts?</p>
  
  <p>TIA,<br>
  Benjy</p>