I want to know how to implement logic for my download button in PHP. I have a file in web server and have a page with download button. I want to start download a file when user press download button. How to implenent? Thanks
Share
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.
Here is how you start a download without letting the user see the real path of the file. Make your link point to download.php?file=filename, and be sure the file exists in the download folder. Then use this code to check if the file exists and let them download it. Optionally, you can put a login check or some other check in it.
In addition, you can also block access to the folder with the files in it with a .htaccess file. If you want to, put the following code in a .htaccess file in the files dir.