Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

PHP
echo "<form method=\"get\" action=\"lics/$site.txt\">";
echo "<div>";
echo "</div>";
echo "<input class=\"submit-button\" type=\"submit\" value=\"Download\">";
echo "</form>";
Posted
Updated 5-Jan-17 16:46pm

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900