/** * return max size for file upload in bytes * @return int $bytes */ public static function getNativeMaxUpload() { return bytes::getNativeMaxUpload(); }
/** * sets a file field with info about max file size * @param string $filename * @param int $max_bytes * @param array $options */ public static function fileWithLabel($filename, $max_bytes, $options = array()) { $bytes = bytes::getNativeMaxUpload(); if ($max_bytes < $bytes) { $bytes = $max_bytes; } self::hidden('MAX_FILE_SIZE', $bytes); $label = lang::translate('Max size per file') . ". "; $size = bytes::bytesToGreek($bytes); $label .= $size; if (isset($options['multiple'])) { $max_files = ini_get('max_file_uploads'); $label .= "<br />"; $label .= lang::translate('Max number of files: <span class="notranslate">{MAX_FILES}</span>', array('MAX_FILES' => $max_files)); } else { $label .= "<br />"; $label .= lang::translate('Only one file at a time'); } if (isset($options['allowed'])) { $label .= '<br />'; $label .= lang::translate('Allowed file-types: ') . $options['allowed']; } self::label($filename, $label); self::file($filename, $options); }