我有一些pdf文件作为blob存储在wordpress数据库中,我需要显示这些文件。这些文件没有直接链接到任何帖子。
我目前拥有的代码是:
<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;
?>
问题是,我没有从浏览器中获得正常的“打开/保存文件”对话框,而是获得了大量:%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�bbdb�$��V �\\"�@�M��k�x
"n���A�d��R �HLfbdXcD\'�3���a endstream endobj startxref 0 %%EOF 42 0 obj
<>stream h�bc2df`H�g�a@& �x�(�x���9X����YH�1
X������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Ĭ)*�����,�-
有人能告诉我如何正确显示BLOB数据吗?