本文整理匯總了PHP中Nette\Application\Request::getFiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getFiles方法的具體用法?PHP Request::getFiles怎麽用?PHP Request::getFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Application\Request
的用法示例。
在下文中一共展示了Request::getFiles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handleRequest
/**
* @param FormInterface $form
* @param Request $request
*/
public function handleRequest(FormInterface $form, $request = null)
{
if (!$request instanceof Request) {
throw new UnexpectedTypeException($request, 'Nette\\Application\\Request');
}
$name = $form->getName();
if ($name === '') {
throw new InvalidArgumentException('Forms are not allowed to have an emtpy string as name.');
}
$method = $form->getConfig()->getMethod();
if ($method !== $request->getMethod()) {
return;
}
if ($method === 'GET') {
$get = $request->getParameters();
// Don't submit GET requests if the form's name does not exist in the request.
if (!isset($get[$name])) {
return;
}
$data = $get[$name];
} else {
$post = $request->getPost();
$files = $request->getFiles();
$default = $form->getConfig()->getCompound() ? [] : null;
$postData = isset($post[$name]) ? $post[$name] : $default;
$filesData = isset($files[$name]) ? $files[$name] : $default;
if (is_array($postData) && is_array($filesData)) {
$data = array_replace_recursive($postData, $filesData);
} else {
$data = $postData ?: $filesData;
}
// Don't submit the form if it is not present in the request.
if (!$data) {
return;
}
}
$form->submit($data, $method !== 'PATCH');
}