note 42951 deleted from function.count by googleguy
| From: | googleguy@php.net | Date: | Mon, 17 Sep 2012 00:13:45 +0000 |
| Subject: | note 42951 deleted from function.count by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190834@lists.php.net to get a copy of this message | ||
Note Submitter: michael at htmlland dot net
----
I have found on upload scripts or on file manipulation scripts that people can trick a classic file
type filter:
example:
<?php
$filename="bob.jpg.wav";
$bits= explode(".",$filename);
$extention= $bits[1];
if($extention == "jpg"){ echo"Not correct"; exit; }
?>
This returns the filename extention as jpg not wav.
One way to change this is to use count() :
example:
<?php
$filename="bob.jpg.wav";
$bits= explode(".",$filename);
$extention= $bits[count($bits) - 1];
if($extention == "jpg"){ echo "Not correct"; exit; }
?>
This returns the filename extention as wav not jpg.