Only adjustments you'll probably want to make are assuming you want the text file to contain more than the most recent query :. Heres what i have now. What I now need is something that will delete the file after it is downloaded. I have heard that i can use PHP to fetch a file, is it posible that i can fetch the file, make it download, then after the download delete it.
I changed it again intead, so that all the outputs are put into a folder, fopen now opens a file. In regards to the delete after download im still interested if anyone knows how I should go about it.
What you should do is instead prohibit them from accessing the files directly via a. Instead, give them a link to a PHP script such as download. The headers I've used are:. Learn more. How can I download a string to the browser using php? Not a text file Ask Question. Asked 9 years ago. Active 9 years ago. Viewed 7k times.
Improve this question. Aust Aust Add a comment. Active Oldest Votes. Improve this answer. Nelson Nelson Wow that's great. One question, why did you put exit;? To make sure there's no more php code that run after echoing the file because if some code outputs anything out that would get into the file and cause problems.
You can skip the exit but make sure your following code does not output anything to the browser. Thnx but unable to fetch data in loop. Its showing only single data in txt file. How should I do? Show 1 more comment. Edson Medina Edson Medina 8, 3 3 gold badges 39 39 silver badges 49 49 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Who owns this outage? Building intelligent escalation chains for modern SRE.
0コメント