php下的msword和pdf浏览下载如何实现

WBOY
Release: 2016-06-13 13:29:54
Original
876 people have browsed it

php下的msword和pdf浏览下载怎么实现
小弟正在做一个老师发布论文要求,然后学生上传论文的网站,是毕业作业,老师放假了,没法问,于是就来找各位大大了
我的网站只允许学生上传pdf或msword文件,然后可以下载,除了downlaod.php外,老师在点击文件链接并不一定是立刻下载,而是打开一个浏览界面,可以选择在线看,或者,需要的话,再下载下来,请问怎么实现。。。。或者,要用js实现?

------解决方案--------------------
不是很好控制。设置好header交给浏览器来做。


http://www.cnblogs.com/persy_php/archive/2010/07/21/1782407.html
http://grow.sinaapp.com/?p=667

设置好header,类似下面这样的

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');


 
header('Content-type: application/pdf'); 
header('Content-Disposition: attachment; filename="downloaded.pdf"'); 
readfile('original.pdf');

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template