I am creating a php file loader and I have some security issues. For example, I do not want to allow the download of ".php" files. As I know, the only way to check the file type is $_FILES['file']['type'], and its value depends on the browser.
I check with multiple browsers and find that when choosing a regular .php file, different browsers return these values:
firefox: application/x-download
chrome: text/plain
safari: text/plain
IE: text/plain
opera: application/octet-stream
I also tried the same experiment with regular .txt files, and all views return text/plainas a mime type.
So the problem is: if I want to allow the download of the .txt file, what should I do to prevent the download of the .php files?
source
share