title: PHP, file_get_contents() returning null for PDF files
body: <p>I would like to get content of a pdf file into a variable. I tried to do this using</p>
  
  <blockquote>
    <p>file_get_contents("file.pdf")</p>
  </blockquote>
  
  <p>but it's returning NULL.  If I do the same with .jpg file for example it's working. Any idea how to overcome this problem? Is there another way? Thanks in advance!</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><strong>Service code:</strong></p>
  
  <pre><code>&lt;?php
  
  function sendAttachment($msg){
  $responsePayloadString = &lt;&lt;&lt;XML
      &lt;payload:receiveReport xmlns:payload="http://wso2.org/wsfphp/samples/mtom"&gt;
          &lt;payload:reports&gt; 
              &lt;payload:report&gt;
                  &lt;payload:content xmlmime:contentType="application/pdf" xmlns:xmlmime="http://www.w3.org/2004/06/xmlmime"&gt;
                      &lt;xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:report1"&gt;&lt;/xop:Include&gt;
                  &lt;/payload:content&gt;
              &lt;/payload:report&gt;
          &lt;/payload:reports&gt;
      &lt;/payload:receiveReport&gt;
  XML;
  $report1 = file_get_contents("samplePDF.pdf");
  
  $responseMessage = new WSMessage($responsePayloadString, 
          array("attachments" =&gt; array("report1" =&gt; $report1),
                  "useWSA" =&gt; TRUE));  
  return $responseMessage;    
  }
  
  $operations = array("receiveReport" =&gt; "sendAttachment");
  
  $service = new WSService(array("operations" =&gt; $operations, 
                                              "requestXOP" =&gt; TRUE, 
                                              "useMTOM" =&gt; TRUE));
  
  $service-&gt;reply();
  
  ?&gt;
  </code></pre>
  
  <p><strong>Client Code:</strong></p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL); 
  ini_set('display_errors', 1);
  
  /******* FirePHP Debug *******/
  require_once('../FirePHPCore/FirePHP.class.php');
  ob_start();
  $firephp = FirePHP::getInstance(true);
  /******* FirePHP Debug *******/
  
  $requestPayloadString = &lt;&lt;&lt;XML
  &lt;receiveReport&gt;&lt;/receiveReport&gt;
  </code></pre>
  
  <p>XML;</p>
  
  <pre><code>try {
  $client = new WSClient(
      array( "to" =&gt; "http://localhost/ReportDL/ReportService.php",
             "useMTOM" =&gt; TRUE,
             "responseXOP" =&gt; TRUE,
             "useWSA" =&gt; TRUE));
  
  $requestMessage = new WSMessage($requestPayloadString);                    
  $responseMessage = $client-&gt;request($requestMessage);
  
  $cid2stringMap = $responseMessage-&gt;attachments;
  $cid2contentMap = $responseMessage-&gt;cid2contentType;
  
  if($cid2stringMap &amp;&amp; $cid2contentMap){
      foreach($cid2stringMap as $i=&gt;$value){
          $f = $cid2stringMap[$i];
          $contentType = $cid2contentMap[$i];
  
          $firephp-&gt;log($f, "pdf");       //DEBUG
  
      }
  }else{
      printf("attachments not received ");
  }
  
  } catch (Exception $e) {
  
  if ($e instanceof WSFault) {
      printf("Soap Fault: %s\n", $e-&gt;Reason);
  } else {
      printf("Message = %s\n",$e-&gt;getMessage());
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p><strong>Edit2:</strong></p>
  
  <pre><code>string '%PDF-1.5
  %âãÏÓ
  2 0 obj
  &lt;&lt;/Length 285/Filter/FlateDecode&gt;&gt;stream
  xœ’_KÃ0Åßó)î£‚Ä{“4i|S¨‚ÓÀžµKiçÚ­0¿½i;ëýƒ#ÐÐÃýœž¦dwŽI
  &amp;ÒàV,qlÁJfŒ�%hCåÙ’­;YÇªÕrÿÎÿêeã|}O@\Æ0,‹&lt;ÌXÃ¤E¯6OW°‹‡z
  ñÑ
  Z¸}¼t]®æ$ä’Õð³ToGÞ!5¾í»R ›4Ù&lt;)¤:•&amp;ž@©ù¸v’4Â®ƒžB®gÁ6è49X»P‚c@uÌíPñîÝÃÒ¿Â“ß|V;Hö/Å&amp;÷Ðw?f    I.MHq²Mö&gt;­w~5k$‘8Šq£ç:õÛmVçù?òi©ý'Ó-Í^$eNðÿ\¥sá6ø(¼`ßè¿Á÷
  endstream
  endobj
  6 0 obj
  &lt;&lt;/Type/Catalog/PageMode/UseNone/Pages 3 0 R&gt;&gt;
  endobj
  7 0 obj
  &lt;&lt;/Creator(BIRT Report Engine 2.6.0 using iText version unknown.)/Producer('... (length=1231)
  </code></pre>