title: file_put_contents Failed to open stream: invalid argument
body: <p>I have this code written in PHP, im using zend server on win 7 as localhost.</p>
  
  <pre><code>&lt;?php
  
  $dir = $_POST['link'];
  // Create DOM from URL or file
  
  require_once 'library/simple_html_dom.php';
  
  $html = file_get_html($dir);
  
  foreach($html-&gt;find('img') as $element){
  
    $image = $element-&gt;src;
    $imglink = $dir . $image;
    $filename = $element-&gt;src;
    $parsed_url = parse_url($filename, PHP_URL_PATH);
    $basename = basename($filename).PHP_EOL;
  
    $filenameOut = __DIR__ . "/images/" . $basename;
  
      $pos = strpos($image, 'data:image');
      if ($pos===false){
       $parsing = parse_url($filename, PHP_URL_HOST);
  
          if ($parsing != NULL){
              file_put_contents($filenameOut, file_get_contents($image));
              }
          else{
          file_put_contents($filenameOut, file_get_contents($imglink));
              }
       }
  
      }
    ?&gt;
  </code></pre>
  
  <p>And it gives me this error </p>
  
  <pre><code>file_put_contents(C:\Program Files (x86)\Zend\Apache2\htdocs/images/chrome-48.png ): failed to open stream: Invalid argument
  </code></pre>
  
  <p>Ive tried putting ways i've read from other questions from this site, but doesnt work.</p>