nli*_*nli 9 php pdf-generation binaryfiles
如何从php5中从数据库中检索的二进制文件生成pdf文件?它是base64编码的,我刚解码它,但不知道接下来要做什么...
dec*_*eze 29
二进制数据只是实际文件,或者更确切地说是该文件的重要内容,只是没有文件名.
$base64 = /* some base64 encoded data fetched from somewhere */;
$binary = base64_decode($base64);
Run Code Online (Sandbox Code Playgroud)
有你有文件的文件数据/内容的$binary变量.从这里开始,这取决于你想做什么.您可以将数据写入文件,然后获得"实际"PDF文件:
file_put_contents('my.pdf', $binary);
Run Code Online (Sandbox Code Playgroud)
您可以使用适当的标头将数据吐出到浏览器,用户将收到类似于PDF文件的内容:
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="my.pdf"');
echo $binary;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22282 次 |
| 最近记录: |