/** * Validate the MIME type of a file upload attribute is in a set of MIME types. * * @param string $attribute * @param array $parameters * @return bool */ protected function validate_mimes($attribute, $parameters) { foreach ($parameters as $extension) { if (File::is($extension, $this->attributes[$attribute]['tmp_name'])) { return true; } } return false; }
/** * Check if a file is one of the valid image types. * If so, return which one it is. If not, return null. * * @param string $file * @return mixed */ private static function image_type($file) { foreach (array('jpg', 'png', 'gif') as $type) { if (File::is($type, $file)) { return $type; } } return null; }