title: Why I am getting corrupted files by downloading it via file_get_contents?
body: <pre><code>    $source_path = 'https://bip.wzp.pl/attachments/' . $filename;  
  
  
      $opts = array(
        'http'=&gt;array(
          'method'=&gt;"GET",
          'header'=&gt;"Content-type: application/pdf",
        )
      );
  
     $context = stream_context_create($opts);    
  
      $data = file_get_contents($source_path, false, $context);
  
      if(($handle = fopen($dest_path, "w"))) {
          fwrite($handle, $data);
          fclose($handle);
          return $filename_converted;
      }
  </code></pre>
  
  <p><code>$source_path</code> is e.g: </p>
  
  <blockquote>
    <p><a href="https://bip.wzp.pl/attachments/28172_Statut" rel="nofollow">https://bip.wzp.pl/attachments/28172_Statut</a> Województwa
    Zachodniopomorskiego.pdf</p>
  </blockquote>
  
  <p>When I trying it browser, a pdf document displayes properly.</p>
  
  <p>But downloaded file via PHP, it is always corrupted.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I checked <code>$data</code> content. It has front page html :/
  It strange putting <code>$source_path</code> to browser returns pdf</p>