} return $return; } } // statically set default language vars - an app that needs to customize messages can do so after including this class (only needs to happen once) UploadHandler::$i18n = array( 'UPLOADHANDLER_ERR_PROCESS_POST_SIZE' => 'POST size of %1$d bytes exceeds the limit set in php.ini#post_max_size of %2$d bytes.', 'UPLOADHANDLER_ERR_PROCESS_NO_INPUT' => 'No file input fields were detected in the POST request.', 'UPLOADHANDLER_ERR_MOVE_EXISTS' => 'Could not move uploaded file "%1$s" to "%2$s" as the destination file already exists and the overwrite option was not set.', 'UPLOAD_ERR_INI_SIZE' => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'UPLOAD_ERR_FORM_SIZE' => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 'UPLOAD_ERR_PARTIAL' => 'The uploaded file was only partially uploaded.', 'UPLOAD_ERR_NO_FILE' => 'No file was uploaded.', 'UPLOAD_ERR_NO_TMP_DIR' => 'Missing a temporary folder.', 'UPLOAD_ERR_CANT_WRITE' => 'Failed to write file to disk.', 'UPLOAD_ERR_EXTENSION' => 'File upload stopped by extension.', ); // statically set some values that do not change throughout the lifetime of a request UploadHandler::$contentLength = (int)@$_SERVER['CONTENT_LENGTH']; UploadHandler::$maxPostSize = UploadHandler::iniBytes(ini_get('post_max_size')); // store this for informational purposes only - php upload support will internally deny uploads which are over this size but client-side code can use this to advise of file size limits UploadHandler::$uploadMaxFilesize = UploadHandler::iniBytes(ini_get('upload_max_filesize')); // the lowest of both maxPostSize and uploadMaxFile size determines the maximum size of a single file upload (may not be accurate to the byte since there's some POST overhead if max POST size happens to be smaller than max file size) UploadHandler::$maxUploadSize = min(UploadHandler::$uploadMaxFilesize, UploadHandler::$maxPostSize);