Php下载而不是在浏览器中显示 [英] Php download instead of showing in the browser

查看:80
本文介绍了Php下载而不是在浏览器中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单PHP页面,它创建一个简单的txt文件。它还有一个按钮来下载相同的文本文件。但是,当点击它时,它显示文件并下载它。我想强制下载它而不是在浏览器中显示(任何浏览器)。



谢谢



我的尝试:



I have a form PHP page which creates a simple txt file. it also has a button to download the same text file. However, when clicked it's showing the file and downloading it. I want to force download it and not show in the browser (Any Browser).

Thanks

What I have tried:

echo "<form method=\"get\" action=\"lics/$site.txt\">";
echo "<div>";
echo "</div>";
echo "<input class=\"submit-button\" type=\"submit\" value=\"Download\">";
echo "</form>";

推荐答案

site.txt \>;
echo < div>< /跨度>;
echo < / div> ;
echo < input class = \\ \\ nsubmit-button \type = \submit \value = \Download \>;
echo < / form> ;
site.txt\">"; echo "<div>"; echo "</div>"; echo "<input class=\"submit-button\" type=\"submit\" value=\"Download\">"; echo "</form>";


该脚本只是在浏览器上打开文本文件,没有下载。学习用PHP处理文件下载的正确方法 - 媒体部门 [ ^ ]
That script just opens the text file on your browser, there is no downloading. Learn The "right way" to handle file downloads in PHP - Media Division[^]


这篇关于Php下载而不是在浏览器中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆