static function validateImage(NFileUpload $control) { $file = $control->getValue(); return $file instanceof NHttpUploadedFile && $file->isImage(); }
static function validateMimeType(NFileUpload $control, $mimeType) { $file = $control->getValue(); if ($file instanceof NHttpUploadedFile) { $type = strtolower($file->getContentType()); $mimeTypes = is_array($mimeType) ? $mimeType : explode(',', $mimeType); if (in_array($type, $mimeTypes, TRUE)) { return TRUE; } if (in_array(preg_replace('#/.*#', '/*', $type), $mimeTypes, TRUE)) { return TRUE; } } return FALSE; }