Validator error for file restrictions
Validator error for file restrictions
![mfitportal](https://secure.gravatar.com/avatar/0d30597b1eb82b2bd90b08b98106442d/?default=https%3A%2F%2Fvanillicon.com%2F0d30597b1eb82b2bd90b08b98106442d_200.png&rating=g&size=120)
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;
};
}
This discussion has been closed.
Answers
I am getting the same error message.
I believe it is a bug within the system, hopefully they recognize it soon.
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
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.