function imce_validate_all in IMCE 6.2
Same name and namespace in other branches
- 6 inc/page.inc \imce_validate_all()
- 7 inc/imce.page.inc \imce_validate_all()
Validate uploaded file.
File
- inc/
imce.page.inc, line 614 - Implements the file browser.
Code
function imce_validate_all(&$file, $imce) {
//fix FILE_EXISTS_ERROR bug. core bug #54223.
if (!$file->destination && variable_get('imce_settings_replace', FILE_EXISTS_RENAME) == FILE_EXISTS_ERROR) {
return array(
t('File browser is set to reject the upload of existing files.'),
);
}
//validate image resolution only if filesize validation passes.
//because user might have uploaded a very big image
//and scaling it may exploit system memory.
$errors = imce_validate_filesize($file, $imce['filesize']);
//image resolution validation
if (empty($errors) && preg_match('/\\.(png|gif|jpe?g)$/i', $file->filename)) {
$errors = array_merge($errors, file_validate_image_resolution($file, $imce['dimensions']));
}
//directory quota validation
if ($imce['quota']) {
$errors = array_merge($errors, imce_validate_quota($file, $imce['quota'], $imce['dirsize']));
}
//file extension validation
if ($imce['extensions'] != '*') {
$errors = array_merge($errors, file_validate_extensions($file, $imce['extensions']));
}
//user quota validation. check it if no errors were thrown.
if (empty($errors) && $imce['tuquota']) {
$errors = imce_validate_tuquota($file, $imce['tuquota'], file_space_used($imce['uid']));
}
return $errors;
}