2015-04-03 116 views
0

我的xampp服务器上有一个.TXT文件,如果用户点击它应该下载的链接,而是在我的浏览器窗口中打开。如何通过点击使用PHP下载.txt文件

我的代码如下:

<a href="<?php echo base_url();?>assets/task/start/<?php echo $files->task_verify_file;?>"><?php echo $files->task_verify_file;?></a> 

任何一个解决问题的感谢

+1

也许你会在这里找到答案 [如何-to-automatically-start-a-download-in-php] [1] [1]:http://stackoverflow.com/questions/40943/how-to-automatically-start-a-download-in-php – AdamM 2015-04-03 12:29:08

回答

0

我没有这样说:

if (file_exists ($file)) { 
    header("Content-Type: text/plain; charset=utf-8"); 
    header("Content-Type: application/force-download"); 
    header("Content-Disposition: attachment; filename=".$filename); 
    readfile($file); 
}