ENHANCEMENT AssetAdmin now uses Upload_Validator instead of setting the rules directly on Upload

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@100058 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-03-01 01:18:01 +00:00 committed by Sam Minnee
parent 55520f1523
commit 4dd3740682

View File

@ -218,9 +218,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) {
$errors = $upload->getErrors();