Let’s say I have this file on my server:
server/myFile.txt
How can I make the user download it with a button click?
Am I missing a simple solution?
I am using jQuery & PHP if there is a solution for that.
thanks,
Alon
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to force a “save-as” dialog box to open for a file type that your web server is configured to output as a readable document (and you don’t want to change that configuration), you need to create a file that modifies the headers so that the browser creates such a dialog.
See the very first example in the php documentation for readfile.
You would then create a PHP file that could be accessed through a normal
a hreflink, which would send the appropriate headers and outputmyFile.txt.