Will this only allow certain extensions?

Posted by Dr Hydralisk on Stack Overflow See other posts from Stack Overflow or by Dr Hydralisk
Published on 2010-06-17T23:13:51Z Indexed on 2010/06/17 23:23 UTC
Read the original article Hit count: 185

Filed under:

I found this snippet that says will only allow certain file types. Will it work and could someone bypass it to upload what ever file type they want? And could someone explain the substr part, i don't get how it works..

<?php
function CheckExt($filename, $ext) {
    $name = strtolower($filename);
    if(substr($name, strlen($name) -3, 3) == $ext)
        return true;
    else
        return false;
}
?>

© Stack Overflow or respective owner

Related posts about php