Back to Files class

Method get

public mixed
get
(mixed $name, mixed $default = null, mixed $filter = 'cmd')
Gets a value from the input data.
Parameters
  • string $name The name of the input property (usually the name of the files INPUT tag) to get.
  • mixed $default The default value to return if the named property does not exist.
  • string $filter The filter to apply to the value.
Returns
  • mixed The filtered input value.
Since
  • 1.7.0
Deprecated
  • 5.0
-
  • \Joomla\CMS\Filter\InputFilter::clean()
Class: Files
Project: Joomla

Method get - Source code

/**
 * Gets a value from the input data.
 *
 * @param   string  $name     The name of the input property (usually the name of the files INPUT tag) to get.
 * @param   mixed   $default  The default value to return if the named property does not exist.
 * @param   string  $filter   The filter to apply to the value.
 *
 * @return  mixed  The filtered input value.
 *
 * @see     InputFilter::clean()
 * @since   1.7.0
 * @deprecated  5.0  Use Joomla\Input\Files instead
 */
public function get($name, $default = null, $filter = 'cmd')
{
    if (isset($this->data[$name])) {
        $results = $this->decodeData(array($this->data[$name]['name'], $this->data[$name]['type'], $this->data[$name]['tmp_name'], $this->data[$name]['error'], $this->data[$name]['size']));
        // Prevent returning an unsafe file unless specifically requested
        if (strtoupper($filter) !== 'RAW') {
            $isSafe = InputFilter::isSafeFile($results);
            if (!$isSafe) {
                return $default;
            }
        }
        return $results;
    }
    return $default;
}