Elgg  Version master
file.php
Go to the documentation of this file.
1 <?php
11 if (!empty($vars['value'])) {
12  echo elgg_format_element('div', [
13  'class' => 'elgg-state elgg-state-warning',
14  ], elgg_echo('fileexists'));
15 
16  unset($vars['value']); // the value attribute isn't supported for file inputs
17 }
18 
19 $vars['class'] = elgg_extract_class($vars, 'elgg-input-file');
20 
22  'type' => 'file',
23 ];
24 
25 $vars = array_merge($defaults, $vars);
26 
27 $max_size = elgg_extract('max_size', $vars, true);
28 unset($vars['max_size']);
29 
30 if ($max_size !== false) {
31  if ($max_size === true) {
33  $upload_max_filesize = elgg_get_ini_setting_in_bytes('upload_max_filesize');
34 
36  }
37 
38  $max_size = (int) $max_size;
39 
40  $vars['data-max-size'] = $max_size;
41  $vars['data-max-size-message'] = elgg_echo('upload:error:ini_size') . ' ' . elgg_echo('input:file:upload_limit', [elgg_format_bytes($max_size)]);
42 
43  elgg_import_esm('input/file');
44 }
45 
46 echo elgg_format_element('input', $vars);
elgg_format_bytes(int $size, int $precision=2)
Format bytes to a human readable format.
Definition: output.php:103
if(!$php_log) $post_max_size
Definition: php.php:11
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_get_ini_setting_in_bytes(string $setting)
Returns a PHP INI setting in bytes.
Definition: elgglib.php:319
elgg_import_esm(string $name)
Helper functions for external files like css/js.
$defaults
Definition: file.php:21
$upload_max_filesize
Definition: php.php:12
$max_size
Definition: file.php:27
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_extract_class(array $array, array|string $existing=[], string $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:277
if(!empty($vars['value'])) $vars['class']
Elgg file input Displays a file input field.
Definition: file.php:19