Re: does this code look like it would check a file extensions, and disallow php files or exe files to be attached
| From: | Darren Whitlen | Date: | Thu, 14 Jun 2007 13:20:57 +0000 |
| Subject: | Re: does this code look like it would check a file extensions, and disallow php files or exe files to be attached | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256990@lists.php.net to get a copy of this message | ||
dave peaachepea wrote:
<?php $filelinks=t3lib_div::_POST('file_name'); // the posting of the file nameA bit easier: <?php // the posting of the file name // Not sure where your getting this from, some class? As long as it gets the filename. $filelinks = t3lib_div::_POST('file_name'); // list of extensions that shouldnt be used $exttypes = array("php3", "php", "exe"); //get the extension after the . $fileextension = substr($filelinks, strpos($filelinks, ".")+1, strlen($filelinks)); // is the extension in the list? if (in_array(strtolower($fileextension), $exttypes)) { // yes it is, so its not allowed echo "mime type doesn't work"; } else { // no its not, so the file is allowed $filelinks = $this->storeFile(); } ?>$exttypes = "php3,php,exe"; // list ofextensions that shouldnt be used$fileextension = substr($filelinks,0,strpos($filelinks,".")); //get theextension after the .if ($fileextension == $exttypes['php']['php3']['exe']) { //if thefile extension equals php, php3, or exeecho "mime type doesn't work"; //if theextension is php, php3, exe, than echo doesn't work }if ($fileextension != $extypes['php']['php3']['exe']) { //if thefile extension doesn't equal php, php3, or exe than// store thefile$filelinks = $this->storeFile(); }?> I'm not a programmer, and I'm very new at php so im sure there are errors and stupid logic in my code. It would be greatly appreciated if anyone here could critique and rip apart my code. thank you, -dave