I have stored pdf file into database i.e blob type. Now I wanna display pdf like
$sqll="select * from pdff";
$query=mysql_query($sqll) or die(mysql_error());
$result=mysql_fetch_array($query);
$content=$result['pdf'];
<object data="<?php echo $content;?>" type="application/pdf" style="height:200px;width:60%"></object>
but in browser it shows..
> endobj 6 0 obj << /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /ColorSpace << /Cs1 7 0 R /Cs2 10 0 R >> /ExtGState << /Gs2 34 0 R /Gs1 35 0 R >> /Font << /F1.0 31 0 R >> /XObject << /Im4 21 0 R /Im1 8 0 R /Im3 16 0 R /Im2 11 0 R /Im5 26 0 R /Im6 32 0 R /Fm3 23 0 R /Fm1 13 0 R /Fm2 18 0 R /Fm4 28 0 R >> /Properties << /Pl2 36 0 R /Pl1 37 0 R >> >> endobj 23 0 obj << /Length 24 0 R /Filter /FlateDecode /Type /XObject /Subtype /Form /FormType 1 /BBox [649 536 669 556] /Resources 25 0 R /Group << /S /Transparency /CS 10 0 R /I true /K false >> >> stream xMŽAƒ0ï}žÀĉmȹ/àÄU+Íÿ¥:(\|˜]ïî etc
and I tried
<object data="<?php echo base64_decode($content);?>" type="application/pdf" style="height:200px;width:60%"></object>
but no use...please help meeee
MySQL has the BLOB datatype that can be used to store files such as . pdf, . jpg, . txt, and the like.
How do I create a blob in HTML? // create Blob from a typed array and strings let hello = new Uint8Array([72, 101, 108, 108, 111]); // "Hello" in binary form let blob = new Blob([hello, ' ', 'world'], {type: 'text/plain'}); let link = document. let link = document.
php // Database Connection $conn = new mysqli('hostname', 'username', 'password', 'database'); //Check for connection error $select = "SELECT * FROM `infopdf`"; $result = $conn->query($select); while($row = $result->fetch_object()){ $pdf = $row->filename; $path = $row->directory; $date = $row->created_date; $file = $ ...
If your data still in Blob
, you need to encode your data using base64_encode()
.
Please try it
<object data="data:application/pdf;base64,<?php echo base64_encode(content) ?>" type="application/pdf" style="height:200px;width:60%"></object>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With