title: Pulling pdf BLOB from database using php and displaying it in a html page not working
body: <p>I am trying to retrieve a blob pdf then display it on the page.
  I am using the following code however only the base 64 string is being displayed instead of the pdf which is my desired output.</p>
  
  <p>The following is the code that I am using.</p>
  
  <pre><code>&lt;?php
      //header('Content-type: application/pdf');
      require 'connect.php';
      $db=mysqli_connect($mysql_host, $mysql_user, $mysql_password,$mysql_dbName);
      $sql = "SELECT * FROM files WHERE id = 1688";
      $sth = $db-&gt;query($sql);
      $result=mysqli_fetch_array($sth);
      $pdf = base64_encode($result['file']);
      echo $pdf;
  ?&gt;
  &lt;object data="&lt;?php echo $pdf ?&gt;" type="application/pdf"&gt;&lt;/object&gt;
  </code></pre>
  
  <p>I have tried using </p>
  
  <pre><code>&lt;object data="data:application/pdf;base64,&lt;?php echo base64_encode(content) ?&gt;" type="application/pdf" style="height:200px;width:60%"&gt;&lt;/object&gt;
  </code></pre>
  
  <p>And also putting it in an iframe like this</p>
  
  <pre><code>&lt;object data="data:application/pdf;base64,&lt;?php echo base64_encode($result['file']) ?&gt;" type="application/pdf"&gt;
      &lt;iframe src="data:application/pdf;base64,&lt;?php echo base64_encode($result['file']) ?&gt;"&gt;&lt;/iframe&gt;
  &lt;/object&gt;
  </code></pre>
  
  <p>But the pdf file fails to load.</p>
  
  <p><strong>-----------EDIT 5/8/17--------</strong></p>
  
  <p>I am now adding an iframe dynamically using the code below yet I get an error saying that </p>
  
  <blockquote>
    <p>Resource interpreted as Document but transferred with MIME type
    application/pdf:</p>
  </blockquote>
  
  <p>here is my newly added javascript</p>
  
  <pre><code>var iframe = document.createElement('iframe');
  
  var src = $('#hiddenBase64').val();//this stores the base64 string
  
  $(iframe).width("100%");
  
  $(iframe).height("100%");
  
  iframe.src = "data:application/pdf;base64," + src;
  
  document.body.appendChild(iframe);
  </code></pre>
  
  <p>Thanks for any help.</p>