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/Validator.inc.php

    r479 r487  
    363363    }
    364364
     365    /*
     366    * Check if the amount of content sent by the browser exceeds the upload_max_filesize value configured in php.ini.
     367    * http://stackoverflow.com/a/24202363
     368    *
     369    * @access   public
     370    * @param    string $form_name The input data to validate.
     371    * @return   bool   True if no errors found, false otherwise.
     372    * @author   Quinn Comendant <quinn@strangecode.com>
     373    * @version  1.0
     374    * @since    20 Aug 2014 14:44:23
     375    */
     376    static public function fileUploadSize($form_name)
     377    {
     378        $upload_max_filesize = phpIniGetBytes('upload_max_filesize');
     379        if (isset($_SERVER['CONTENT_LENGTH']) && 0 != $upload_max_filesize && $_SERVER['CONTENT_LENGTH'] > $upload_max_filesize) {
     380            return false;
     381        }
     382        return true;
     383    }
     384
    365385} // THE END
    366386
Note: See TracChangeset for help on using the changeset viewer.