ENHANCEMENT AssetAdmin now uses Upload_Validator instead of setting the rules directly on Upload (from r100058)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111618 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-04 05:47:30 +00:00
parent 65aa49d564
commit 70105f066e

View File

@ -199,9 +199,15 @@ JS
if(!File::$apply_restrictions_to_admin && Permission::check('ADMIN')) {
$valid = true;
} else {
// Set up the validator instance with rules
$validator = new Upload_Validator();
$validator->setAllowedExtensions(File::$allowed_extensions);
$validator->setAllowedMaxFileSize(self::$allowed_max_file_size);
// Do the upload validation with the rules
$upload = new Upload();
$upload->setAllowedExtensions(File::$allowed_extensions);
$upload->setAllowedMaxFileSize(self::$allowed_max_file_size);
$upload->setValidator($validator);
$valid = $upload->validate($tmpFile);
if(!$valid) {
$errorsArr = $upload->getErrors();