dorkahemp972157683 2019-05-01 12:00
浏览 183

file_get_contents方法在调用php API时返回一些带有奇怪符号的值。 无法在浏览器中查看

Getting Strange response from file_get_contents Method in php

$binaryfile = file_get_contents('https://xyz.abc.ee/api/file.php?hash='.$final_hash_std_cert.'&action=getFile&name='.$cert, false, stream_context_create($stream_opts));
echo $binaryfile;

on ajax side i'm doing this :

productCert = $(this).attr('data-cert');
$.ajax({
    type: "POST", // use $_POST method to submit data
    url: my_ajaxurl, // where to submit the data
    data: {
        action     : 'load_cert_action',
        cert_url : productCert, // PHP: $_POST['first_name']
    },
    success:function(data) {
        console.log(data); // here i'm getting strange output
        //window.location.assign(data);
        // var pdfWindow = window.open("");
        // pdfWindow.document.write(data)
    },
    error: function(errorThrown){
        console.log(errorThrown); // error
    }
});

Getting this response in console :

%PDF-1.5 %���� 5 0 obj <>stream H���yTSw�oɞ����c [���5, �� �BHBK!aP�V�X��=u����:X��K�è���Z\;v^�����N�����߽��~��w��.M�h�a

this is just first four five lines. this is very large string of strange charters. I think issue with some UTF format. Not so sure. Help me please.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测