本文介绍了强制在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中下载文件
发布评论