Zend Framework:如何从 mySql Blob 字段下载文件

发布于 2024-08-28 22:10:46 字数 155 浏览 2 评论 0原文

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

如何将此二进制数据转换为原始文件?如何在 zend 中做到这一点?

谢谢

I am uploading files(any type) in MySql tables's blob field. Now I am able to get binary data from that field and when I print it, it shows binary data in firbug console. But I want to download that file as it was uploaded.

How can I convert this binary data into orignal file? How to do it in zend?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離人涙 2024-09-04 22:10:46

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

<?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;
?> 

You need to set the headers at minimum you need

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

Or preferablly

<?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;
?> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文