Validator error for file restrictions

Validator error for file restrictions

mfitportalmfitportal Posts: 20Questions: 7Answers: 0
edited March 2019 in DataTables

I am using the editor for a site that I am working on and I came across this error
Illegal string offset 'name' in ..\Editor\Validate.php on line 1064
I'm unsure why this error is occurring as the validate file should be up to date. For the server side script, I followed the example that is posted on the site. I'll put the segment of code that it is referring to.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * File validation methods
    */
    static function fileExtensions ( $extensions, $msg="This file type cannot be uploaded." ) {
        return function ( $file ) use ( $extensions, $msg ) {
            $extn = pathinfo($file['name'], PATHINFO_EXTENSION);

            for ( $i=0, $ien=count($extensions) ; $i<$ien ; $i++ ) {
                if ( strtolower( $extn ) === strtolower( $extensions[$i] ) ) {
                    return true;
                }
            }

            return $msg;
        };
    }

    static function fileSize ( $size, $msg="Uploaded file is too large." ) {
        return function ( $file ) use ( $size, $msg ) {
            return $file['size'] > $size ?
                $msg :
                true;
        };
    }

Answers

  • j92694j92694 Posts: 1Questions: 0Answers: 0

    I am getting the same error message.

  • mfitportalmfitportal Posts: 20Questions: 7Answers: 0

    I believe it is a bug within the system, hopefully they recognize it soon.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    What versions of Editor and PHP are you using please? This example makes use of that validator and doesn't show any errors.

    Thanks,
    Allan

  • ShowGroundsShowGrounds Posts: 2Questions: 1Answers: 0

    For those getting upload error, please note that the validator must be used on the Upload::inst. Don't use it on the Field::inst.

This discussion has been closed.