duanli6834 2011-11-14 12:00
浏览 59
已采纳

如何使用PHP创建存储在MYSQL数据库中的文件的文件下载链接?

I know I can just upload the file to a folder in my server, save the directory location to the MYSQL database, and create a download link based on that directory location but what happens when you store a file like a pdf or zip archive directly on the MYSQL database? How do you retrieve that data and create a file download link then?

  • 写回答

3条回答 默认 最新

  • douzhan1868 2011-11-14 12:04
    关注

    You will have to set some content headers before outputting the data from your database, like:

    header("Content-type: $type");
    header("Content-length: $size");
    header("Content-Disposition: attachment; filename=$name");
    header("Content-Description: PHP Generated Data");
    echo $data;
    

    Full example at http://onlamp.com/pub/a/php/2000/09/15/php_mysql.html?page=3

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义