Hi Guys,
This question should be an easy one to answer for any Expert at EE.
How can I block all & any file (with the following extensions: .html ; .php; .exe;) from uploading to our server?
Currently I'm using the following line of code successfully, but it doesn't go far enough — it's limited to exact filenames.
This is my code:
[code]
if($File=="index.html" || $File=="index.php" || $File=="default.html" || $File=="default.php")
{ echo "Sorry! You can't upload that kind of file";}
[/code]
Thanks for the help.
$not_allowed= array("html ", "php", "exe");
if (in_array($file, $not_allowed )) {
echo "Sorry! You can't upload that kind of file";
}
$pathparts = pathinfo('/www/htdocs/inc/index.php');
I tried using $FilePATH = $_SERVER['PATH_INFO']; to get the path, but it comes back empty.$pathparts = pathinfo('$File');
Presto! It worked!$file = "somefile.php"; //FILE WE AR CHECKING
$file_type = substr($file,-3); //GET THE FILE TYPE BY THE LAST THREE CHARACTERS
$not_allowed= array("html ", "php", "exe"); // NOT ALLOWED LIST
if (in_array($file_type, $not_allowed )) { // CHECK IF FILE IS IN THE NOT ALLOWED LIST
echo "Sorry! You can't upload that kind of file";
} else {
echo "This is a good file";
}
I'll give both approaches a shot tomorrow and let you know how it works out.
At first glance it looks quite logical.
Thanks
Sas