i would like to check the uploaded files via manager for image type and check the width of that image. In case the uploaded image is larger then a defined width of pixel i would like to prevent this file from upload.
I can check the width and return an error message for the user - but how can i prevent the Upload.
I have the following code inside a plugin triggered on the event “OnFileManagerBeforeUpload”:
list($width, $height, $type, $attr) = getimagesize($file['tmp_name']);
if ($width >=10000 xor $height >= 10000) {
$source->addError('', 'Error: Filesize is over 10.000 px.');
return;
}
It looks like the code checks if $file['error'] is not 0 or if $file['name'] is empty after “OnFileManagerBeforeUpload” is invoked and skips the file if it is the case.