PHP的base64 EN code PDF文件 [英] PHP base64 encode a pdf file

查看:538
本文介绍了PHP的base64 EN code PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个API,我可以将文档发送到类似Dropbox的。根据该文件,这是发送文件需要BASE64 EN codeD数据。

I am using an API where I can send a document to something like dropbox. According to the documentation, the file which is sent needs to be BASE64 encoded data.

因此​​,我想这样的事情

As such, I am trying something like this

$b64Doc = chunk_split(base64_encode($this->pdfdoc));

其中, $这个 - 方式> pdfdoc 是路径到我的PDF文档

Where $this->pdfdoc is the path to my PDF document.

目前,该文件被发送过来,但似乎无效(无显示)。

At the moment, the file is being sent over but it seems invalid (displays nothing).

我是我的PDF转换正确为Base64 EN codeD数据?

Am I correctly converting my PDF to BASE64 encoded data?

感谢

推荐答案

base64_en code 需要一个字符串输入。因此,所有你正在做的是编码的路径。你应该抓住文件的内容

base64_encode takes a string input. So all you're doing is encoding the path. You should grab the contents of the file

$b64Doc = chunk_split(base64_encode(file_get_contents($this->pdfdoc)));

这篇关于PHP的base64 EN code PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆