title: Curl Image using php but empty file is created
body: <p>I'm trying to curl image using his code. But it works for some images links but images from wikipedia/wikimedia aren't working. e.g. <code>https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Johan_van_der_Veeken.jpg/266px-Johan_van_der_Veeken.jpg</code></p>
  
  <p>Code:</p>
  
  <pre><code>&lt;form method="post"&gt;
  &lt;input type="text" name="image_url"&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;?php
  
  if($_SERVER['REQUEST_METHOD'] == 'POST'){
   $image =$_POST["image_url"];
  $path_parts = pathinfo($image);
  $rename=$path_parts['filename'];
  $extension=$path_parts['extension'];
  
  $ch = curl_init($image);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
  $rawdata=curl_exec ($ch);
  curl_close ($ch);
  
  $fp = fopen("dowloads/$rename.$extension",'w');
  fwrite($fp, $rawdata);
  fclose($fp);
  echo "$rename.jpg";
  }
  ?&gt;
  </code></pre>
  
  <p>Error:<br>
  When I try to open file in windows photo viewer it says <code>can't display this picture because the file is empty.</code></p>