I am trying to reduce the file size of an image uploaded to no more than 200 kb. It does not appear to be working as I can upload larger files. This is what I have:
if($this->canAttach()) {
$fileUploadField = new FileField("Attachment", "Attach File (files must be less than 200 kb in size)");
$f_validator = new Upload_Validator();
$f_validator->setAllowedExtensions(array('pdf','png','jpg')); // set your extensions here
$f_validator->setAllowedMaxFileSize( array('*' => 204800) );
$fileUploadField->setValidator($f_validator);
$fields->push(
$fileUploadField
);
}
and this....
if($this->canAttach()) {
$fileUploadField = new FileField("Attachment", "Attach File");
$f_validator = new Upload_Validator();
$f_validator->setAllowedExtensions(array('pdf','png','jpg')); // set your extensions here
$f_validator->setAllowedMaxFileSize( array('*' => 204800) );
$fileUploadField->setValidator($f_validator);
$fields->insertBefore($fileUploadField, 'CurrentAttachments');
}
Where am I going wrong?
Thanks for your help.