【问题标题】:How to encode pdf file in base64 format?如何以base64格式编码pdf文件?
【发布时间】:2018-06-13 10:04:46
【问题描述】:

我就是这样做的。这是正确的吗?

    $filename = "../pdfs/reactjs_tutorial.pdf";
    $handle = fopen($filename, 'rb');
    $contents = fread($handle,filesize($filename));
    fclose($handle);
    $encoded = chunk_split(base64_encode($contents));

/*This is how I have done*/

【问题讨论】:

  • 除了通过 Base-64 编码器运行文件并发送结果吗?
  • 我已将其网址保存在数据库中,但根据 api 要求,我需要将 pdf 文件本身编码为 base 64 格式。
  • 我需要发送编码格式的pdf文件
  • 您是否尝试过在 Google 上搜索 base64 encode pdf file,您会发现数以千计的有用工具和指南。
  • 不难base64_encode(file_get_contents('/path/to/file.pdf'));

标签: php pdf base64


【解决方案1】:
      $query1 = mysqli_query($con, "SELECT  `offer_id` ,  `offer_img_url` ,  `terms` FROM  `offers` LEFT JOIN system ON system.shop_id = offers.shop_id LEFT JOIN bill ON bill.sys_id = system.sys_id WHERE yb_id =  '$yb_id' LIMIT 0 , 30 ");
  if(mysqli_affected_rows($con)>0)
      {
        $data4 = array();
      while ($row = mysqli_fetch_array($query1))
         {
        $data4['offer_id'] = $row['offer_id'];
        $data4['offer_img_url'] = base64_encode($row['offer_img_url']);
        $data4['terms'] = $row['terms'];
         $data2[] = $data4;
      }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-07
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 2010-09-17
    • 1970-01-01
    相关资源
    最近更新 更多