dongxiaoke2018 2019-06-23 12:25
浏览 105
已采纳

php如何从二进制数据中显示文件

I have function that run web-service and bring me binary file:

$params->xmlRequest = $paramsStr;

$result = $s->__call("SubmitXmlString",array($params));

$obj_pros = get_object_vars($result);
$xml =  $obj_pros['SubmitXmlStringResult']; 
$xml = simplexml_load_string($xml); 

return ($xml);  

example for response:

<PnrGetReportDoc ReportName="ExternalDocument">
    <Report ID="6214" Type="pdf" Name="file name" IsCompressed="1">
        <![CDATA[JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAQolJU......................VPRg==]]>
        </Report>
    <ReportImages>
</ReportImages>
</PnrGetReportDoc>

I would like to ECHO the content in order to display the file

I tried to echo the binary but: 1. PDF isn't display

  1. binary characters start without the opening notes: <![CDATA[

This is my php file where i'm trying to display the file:

header('Content-type: application/'pdf);
$fileData = get_file_data ($_GET['fileID']);

echo $fileData->Report;
  • 写回答

1条回答 默认 最新

  • dongshi4589 2019-06-23 13:57
    关注

    That is not binary. Precisely, XML is well known for being a plain text data format.

    From the sample data you've shared I imagine it's Base64, a popular algorithm to encode binary data as plain text. PHP has a native function to decode it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'