title: Error when copying img with a cURL script (php)
body: <p>I made a nice simple userscript:<br>
  When I browse the web, I can "bookmark" any image in 1 click<br>
  My userscript  </p>
  
  <ol>
      <li>Grab the img src  </li>
      <li>Grab the url of the webpage  </li>
      <li>Copy the .jpg .png .gif to my server </li> 
  </ol>
  
  <p>Everything works perfectly, BUT in some cases, the script cannot copy the file...<br>
  Actually the file is created but do not contains the img data, it only contains the content of an error webpage:</p>
  
  
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  &lt;html&gt;&lt;head&gt;
  &lt;title&gt;403 Forbidden&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Forbidden&lt;/h1&gt;
  &lt;p&gt;You don't have permission to access /data/x/xxx_xxx_x.jpg on this server.&lt;/p&gt;
  &lt;p&gt;Additionally, a 403 Forbidden
  error was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;
  &lt;hr&gt;
  &lt;address&gt;Apache Server at xxxxxxxx.net Port 80&lt;/address&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>The "copy" code (php):</p>
  
  <pre><code>$ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, $urlimg); 
  curl_setopt($ch, CURLOPT_HEADER, false); 
  curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
  set_time_limit(300); # 5 minutes for PHP 
  curl_setopt($ch, CURLOPT_TIMEOUT, 300); # and also for CURL 
  $path = $dirpix.'/'.$aa.'/'.$mm;
  if ( ! is_dir($path)) {
      mkdir($path);
  }
  $outfile = fopen($path.'/'.$id.'.'.$ext, 'wb'); 
  curl_setopt($ch, CURLOPT_FILE, $outfile); 
  curl_exec($ch); 
  fclose($outfile); 
  curl_close($ch); 
  </code></pre>
  
  <p>Maybe the website blocks that kind of "copy" script?
  Thanks!</p>