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

解决方案 »

  1.   

    不是很好控制。设置好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');