Symfony\Component\DomCrawler\Form::getPhpFiles PHP Method

getPhpFiles() public method

This method converts fields with the array notation (like foo[bar] to arrays) like PHP does. The returned array is consistent with the array for field values (@see getPhpValues), rather than uploaded files found in $_FILES. For a compound file field foo[bar] it will create foo[bar][name], instead of foo[name][bar] which would be found in $_FILES.
public getPhpFiles ( ) : array
return array An array of file field values
    public function getPhpFiles()
    {
        $values = array();
        foreach ($this->getFiles() as $name => $value) {
            $qs = http_build_query(array($name => $value), '', '&');
            if (!empty($qs)) {
                parse_str($qs, $expandedValue);
                $varName = substr($name, 0, strlen(key($expandedValue)));
                $values = array_replace_recursive($values, array($varName => current($expandedValue)));
            }
        }

        return $values;
    }

Usage Example

    /**
     * Submits a form.
     *
     * @param Form  $form   A Form instance
     * @param array $values An array of form field values
     *
     * @api
     */
    public function submit(Form $form, array $values = array())
    {
        $form->setValues($values);

        return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles());
    }
All Usage Examples Of Symfony\Component\DomCrawler\Form::getPhpFiles