I have a form in my website where users can upload files in TXT. These files are always PHP file that I request users to change the extension so it will make no harm to the server (which is running APACHE + PHP).
The file has to be uploaded to the www directory cause later they can download the file if necessary. I cannot save the file in the root (above public_html) cause the user has to have access to download the file at anytime. The problem is that when the user opens the URL containing the PHP file it would be executed and it would big a hole in the security.
So far I am asking users to upload the file as txt but I want to make it more professional and allow them to upload it as *.php. How can I prevent attacks of people uploading files with security theatens from damaging my server?
Thank you.