强制在php中下载文件

编程入门 行业动态 更新时间:2024-10-27 10:28:43
本文介绍了强制在php中下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我建立了一个简单的文件管理器,用户可以在其中下载任何类型的文件,例如pdf,word或gif文件.我希望所有人都下载文件,而不是在浏览器中查看文件.上载的文件名存储在数据库中.

I have built a simple file manager where users can download any type of file such as pdf, word or gif files. I want all of them to download file rather than view it in browsers. The uploaded filenames are stored in database.

推荐答案

<?php // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); ?>

php/manual/en/function.header.php

更多推荐

强制在php中下载文件

本文发布于:2023-06-04 22:09:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/506086.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!