title: How do I make php wait for curl to finish before continuing?
body: <p>It seems if I do something like</p>
  
  <pre><code>$file = fopen($filepath, "w");
  $CR = curl_init();
  curl_setopt($CR, CURLOPT_URL, $source_path);
  curl_setopt($CR, CURLOPT_POST, 1);
  curl_setopt($CR, CURLOPT_FAILONERROR, true);
  curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($CR, CURLOPT_FILE, $file);
  $result = curl_exec( $CR );
  $error = curl_error( $CR );
  print filesize($filepath);
  </code></pre>
  
  <p>I get a different result than if I just run</p>
  
  <pre><code>print filesize($filepath);
  </code></pre>
  
  <p>a second time.  My guess is that curl is still downloading when do a filesize().</p>