<i id='izulN'><tr id='izulN'><dt id='izulN'><q id='izulN'><span id='izulN'><b id='izulN'><form id='izulN'><ins id='izulN'></ins><ul id='izulN'></ul><sub id='izulN'></sub></form><legend id='izulN'></legend><bdo id='izulN'><pre id='izulN'><center id='izulN'></center></pre></bdo></b><th id='izulN'></th></span></q></dt></tr></i><div id='izulN'><tfoot id='izulN'></tfoot><dl id='izulN'><fieldset id='izulN'></fieldset></dl></div>
<tfoot id='izulN'></tfoot>

        <bdo id='izulN'></bdo><ul id='izulN'></ul>

    1. <small id='izulN'></small><noframes id='izulN'>

      <legend id='izulN'><style id='izulN'><dir id='izulN'><q id='izulN'></q></dir></style></legend>

      1. 从 MySQL 流式传输二进制文件以使用 PHP 下载

        Stream binary file from MySQL to download with PHP(从 MySQL 流式传输二进制文件以使用 PHP 下载)
        <tfoot id='VWAvI'></tfoot>
          • <bdo id='VWAvI'></bdo><ul id='VWAvI'></ul>

            • <small id='VWAvI'></small><noframes id='VWAvI'>

              <legend id='VWAvI'><style id='VWAvI'><dir id='VWAvI'><q id='VWAvI'></q></dir></style></legend>

                  <tbody id='VWAvI'></tbody>
                <i id='VWAvI'><tr id='VWAvI'><dt id='VWAvI'><q id='VWAvI'><span id='VWAvI'><b id='VWAvI'><form id='VWAvI'><ins id='VWAvI'></ins><ul id='VWAvI'></ul><sub id='VWAvI'></sub></form><legend id='VWAvI'></legend><bdo id='VWAvI'><pre id='VWAvI'><center id='VWAvI'></center></pre></bdo></b><th id='VWAvI'></th></span></q></dt></tr></i><div id='VWAvI'><tfoot id='VWAvI'></tfoot><dl id='VWAvI'><fieldset id='VWAvI'></fieldset></dl></div>

                  本文介绍了从 MySQL 流式传输二进制文件以使用 PHP 下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我将 Excel 电子表格存储在 MySQL 表 longblob 字段中.我需要检索这些数据,然后将其作为可下载文件流式传输给用户,最好不要先将其写入磁盘.

                  I have Excel spreadsheets stored in a MySQL table longblob field. I need to retrieve this data and then stream it to the user as a downloadable file, preferably without writing it to disk first.

                  可能吗?

                  编辑 - 嗯,刚刚想通了......发布在下面的答案中.

                  Edit - Eh, just figured it out... Posted in answer below.

                  推荐答案

                  function getfile($blockid)
                  {
                      global $msa_db;
                      $sql = "select filename, filedata from blocks where blockid = '$blockid'";
                      $query = mysql_query($sql, $msa_db);
                      $result['filename'] = mysql_result($query,0,0);
                      $result['filedata'] = mysql_result($query,0,1);
                      return $result;
                  
                  }
                  
                  function download($fileinfo)
                  {
                      $file = base64_decode($fileinfo['filedata']);
                      header("Cache-Control: no-cache private");
                      header("Content-Description: File Transfer");
                      header('Content-disposition: attachment; filename='.$fileinfo['filename']);
                      header("Content-Type: application/vnd.ms-excel");
                      header("Content-Transfer-Encoding: binary");
                      header('Content-Length: '. strlen($file));
                      echo $file;
                      exit;
                  }
                  
                  $fileinfo = getfile($blockid);
                  
                  download($fileinfo);
                  

                  这篇关于从 MySQL 流式传输二进制文件以使用 PHP 下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)

                    <i id='z0Nhy'><tr id='z0Nhy'><dt id='z0Nhy'><q id='z0Nhy'><span id='z0Nhy'><b id='z0Nhy'><form id='z0Nhy'><ins id='z0Nhy'></ins><ul id='z0Nhy'></ul><sub id='z0Nhy'></sub></form><legend id='z0Nhy'></legend><bdo id='z0Nhy'><pre id='z0Nhy'><center id='z0Nhy'></center></pre></bdo></b><th id='z0Nhy'></th></span></q></dt></tr></i><div id='z0Nhy'><tfoot id='z0Nhy'></tfoot><dl id='z0Nhy'><fieldset id='z0Nhy'></fieldset></dl></div>
                  1. <tfoot id='z0Nhy'></tfoot>

                    <legend id='z0Nhy'><style id='z0Nhy'><dir id='z0Nhy'><q id='z0Nhy'></q></dir></style></legend>

                      <small id='z0Nhy'></small><noframes id='z0Nhy'>

                        <tbody id='z0Nhy'></tbody>

                            <bdo id='z0Nhy'></bdo><ul id='z0Nhy'></ul>