【问题标题】:Zend Framework: How to download file from mySql Blob fieldZend 框架:如何从 mySql Blob 字段下载文件
【发布时间】:2011-02-06 23:09:02
【问题描述】:

我正在 MySql 表的 blob 字段中上传文件(任何类型)。现在我可以从该字段中获取二进制数据,当我打印它时,它会在 firbug 控制台中显示二进制数据。但我想在上传时下载该文件。

如何将此二进制数据转换为原始文件?在zend中怎么做?

谢谢

【问题讨论】:

    标签: mysql zend-framework file blob


    【解决方案1】:

    您需要将标题设置为您需要的最低限度

    <?php
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"".$filename."\";");
    echo $data;
    exit;
    ?> 
    

    或者最好

    <?php
    header("Pragma: public");
          header("Expires: 0");
          header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
          header("Cache-Control: private",false);
          header ( "Content-Type: $filedatatype" );
          header("Content-Disposition: attachment; filename=\"".$FileObj->name."\";");
          header("Content-Transfer-Encoding:­ binary");
          header("Content-Length: ".$filesize);
    echo $data;
    exit;
    ?> 
    

    【讨论】:

      猜你喜欢
      • 2012-02-04
      • 2019-03-31
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 2012-05-19
      • 2015-11-10
      • 1970-01-01
      相关资源
      最近更新 更多