public function validate($path, $filename = null)
    {
        $pathinfo = isset($filename) ? pathinfo($filename) : pathinfo($path);

        if (empty($pathinfo['filename'])) {
            return $this->translation->text('Unknown filename');
        }

        if (empty($pathinfo['extension'])) {
            return $this->translation->text('Unknown file extension');
        }

        if ($this->handler === false) {
            return true;
        }

        if (!isset($this->handler)) {
            try {
                $this->setHandlerByExtension($pathinfo['extension']);
            } catch (Exception $ex) {
                return $ex->getMessage();
            }
        }

        if (!isset($this->destination) && isset($this->handler['path'])) {
            $this->destination = $this->handler['path'];
        }

        try {
            return $this->validateHandler($path, $pathinfo['extension']);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
public function validate($path, $filename = null)
    {
        $pathinfo = isset($filename) ? pathinfo($filename) : pathinfo($path);

        if (empty($pathinfo['filename'])) {
            return $this->translation->text('Unknown filename');
        }

        if (empty($pathinfo['extension'])) {
            return $this->translation->text('Unknown file extension');
        }

        if ($this->handler === false) {
            return true;
        }

        if (!isset($this->handler)) {
            try {
                $this->setHandlerByExtension($pathinfo['extension']);
            } catch (Exception $ex) {
                return $ex->getMessage();
            }
        }

        if (!isset($this->destination) && isset($this->handler['path'])) {
            $this->destination = $this->handler['path'];
        }

        try {
            return $this->validateHandler($path, $pathinfo['extension']);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
public function validate ( $ path , $ filename = null ) { $ pathinfo = isset ( $ filename ) ? pathinfo ( $ filename ) : pathinfo ( $ path ) ; if ( empty ( $ pathinfo [ 'filename' ] ) ) { return $ this -> translation -> text ( 'Unknown filename' ) ; } if ( empty ( $ pathinfo [ 'extension' ] ) ) { return $ this -> translation -> text ( 'Unknown file extension' ) ; } if ( $ this -> handler === false ) { return true ; } if ( ! isset ( $ this -> handler ) ) { try { $ this -> setHandlerByExtension ( $ pathinfo [ 'extension' ] ) ; } catch ( Exception $ ex ) { return $ ex -> getMessage ( ) ; } } if ( ! isset ( $ this -> destination ) && isset ( $ this -> handler [ 'path' ] ) ) { $ this -> destination = $ this -> handler [ 'path' ] ; } try { return $ this -> validateHandler ( $ path , $ pathinfo [ 'extension' ] ) ; } catch ( Exception $ ex ) { return $ ex -> getMessage ( ) ; } }
Validate a file
@param string $path
@param null|string $filename
@return boolean|string
Validate a file