You are here

function imce_validate_all in IMCE 7

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_validate_all()
  2. 6 inc/page.inc \imce_validate_all()

Validate uploaded file.

File

inc/imce.page.inc, line 664
Implements the file browser.

Code

function imce_validate_all($file, $imce) {

  // 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']));
  }

  // 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;
}