Ignore:
Timestamp:
Aug 20, 2014 11:56:27 AM (10 years ago)
Author:
anonymous
Message:

Added Validator::fileUploadSize(), phpIniGetBytes(), and fixed php version error checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FormValidator.inc.php

    r484 r487  
    595595        }
    596596    }
     597    /**
     598     * Check whether a file was selected for uploading. If file is missing, it's an error.
     599     *
     600     * @param  string $form_name the name of the incoming form variable
     601     * @param  string $msg       the message to display on error
     602     *
     603     * @return bool   true if no errors found, false otherwise
     604     */
     605    public function fileUploadSize($form_name, $msg='')
     606    {
     607        if (Validator::fileUploadSize($form_name)) {
     608            return true;
     609        } else {
     610            $msg = '' == $msg ? sprintf(_("Maximum filesize exceeded. Got %s, but limit is %s."), humanFileSize($_SERVER['CONTENT_LENGTH']), humanFileSize(phpIniGetBytes('upload_max_filesize'))) : $msg;
     611            $this->addError($form_name, $msg);
     612            return false;
     613        }
     614    }
    597615
    598616} // THE END
Note: See TracChangeset for help on using the changeset viewer.