public function is_allowed_file_type($file)
    {
        $path_parts = pathinfo($file);

        // if there is no extension
        if (!isset($path_parts['extension'])) {
            // we check if no extension file are allowed
            return (bool)$this->config['security']['allowNoExtension'];
        }

        $extensions = array_map('strtolower', $this->config['upload']['restrictions']);

        if($this->config['upload']['policy'] == 'DISALLOW_ALL') {
            if(!in_array(strtolower($path_parts['extension']), $extensions)) {
                return false;
            }
        }
        if($this->config['upload']['policy'] == 'ALLOW_ALL') {
            if(in_array(strtolower($path_parts['extension']), $extensions)) {
                return false;
            }
        }

        return true;
    }
public function is_allowed_file_type($file)
    {
        $path_parts = pathinfo($file);

        // if there is no extension
        if (!isset($path_parts['extension'])) {
            // we check if no extension file are allowed
            return (bool)$this->config['security']['allowNoExtension'];
        }

        $extensions = array_map('strtolower', $this->config['upload']['restrictions']);

        if($this->config['upload']['policy'] == 'DISALLOW_ALL') {
            if(!in_array(strtolower($path_parts['extension']), $extensions)) {
                return false;
            }
        }
        if($this->config['upload']['policy'] == 'ALLOW_ALL') {
            if(in_array(strtolower($path_parts['extension']), $extensions)) {
                return false;
            }
        }

        return true;
    }
public function is_allowed_file_type ( $ file ) { $ path_parts = pathinfo ( $ file ) ; // if there is no extension if ( ! isset ( $ path_parts [ 'extension' ] ) ) { // we check if no extension file are allowed return ( bool ) $ this -> config [ 'security' ] [ 'allowNoExtension' ] ; } $ extensions = array_map ( 'strtolower' , $ this -> config [ 'upload' ] [ 'restrictions' ] ) ; if ( $ this -> config [ 'upload' ] [ 'policy' ] == 'DISALLOW_ALL' ) { if ( ! in_array ( strtolower ( $ path_parts [ 'extension' ] ) , $ extensions ) ) { return false ; } } if ( $ this -> config [ 'upload' ] [ 'policy' ] == 'ALLOW_ALL' ) { if ( in_array ( strtolower ( $ path_parts [ 'extension' ] ) , $ extensions ) ) { return false ; } } return true ; }
Check if file is allowed to upload regarding the configuration settings
@param string $file
@return bool
Check if file is allowed to upload regarding the configuration settings