Displaying BLOB PDF File
-
Hi,
I have some pdf files that are stored in the wordpress database as a blob and I need to display these files. The files are not linked to any posts directly.The code I have currently is:
<div class="wrap"> <?php global $wpdb; $mydataset = $wpdb->get_row("SELECT * FROM wp_attachments WHERE ID = 1119"); $recordID = $mydataset->ID; $FileType = $mydataset->FileType; $FileSize = $mydataset->FileSize; $FileName = $mydataset->FileName; $FileContent = $mydataset->FileContent; add_action( 'send_headers', 'add_header_info' ); function add_header_info() { header("Content-Type: ". $FileType); header("Content-Length: ". $FileSize); header("Content-Disposition: attachment; filename=". $FileName); echo $FileContent; } echo $FileContent; ?>
The problem is that the I do not get the normal open/save file dialogue box from the browser, but rather I get a whole lot of:
%PDF-1.5 %???? 21 0 obj <> endobj 36 0 obj <>/Filter/FlateDecode/ID[<3D64A2F9453F2A4097AB5FEE91CB4D65>]/Index[21 22]/Info 20 0 R/Length 78/Prev 58282/Root 22 0 R/Size 43/Type/XRef/W[1 2 1]>>stream h?bbd
b
?$??V ?\"?@?M??k?x"n???A?d??R ?HLf
bdXcD'?3??
?a endstream endobj startxref 0 %%EOF 42 0 obj <>stream h?bc
2d
f`H?g?a@& ?x?(?x???9X????YH?1X??????CC?C???A?As?d?+,??$??p00??iF ?bn??&?? ??q? endstream endobj 22 0 obj <> endobj 23 0 obj <> endobj 24 0 obj <>stream h?S?n?@??yLT?{??c?m?X?m?)*?????,?-Can anyone please advise me on how I can correctly display the BLOB data?
- The topic ‘Displaying BLOB PDF File’ is closed to new replies.