当前位置: 首页>>代码示例>>PHP>>正文


PHP ServerRequestInterface::getUploadedFiles方法代码示例

本文整理汇总了PHP中Psr\Http\Message\ServerRequestInterface::getUploadedFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestInterface::getUploadedFiles方法的具体用法?PHP ServerRequestInterface::getUploadedFiles怎么用?PHP ServerRequestInterface::getUploadedFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\ServerRequestInterface的用法示例。


在下文中一共展示了ServerRequestInterface::getUploadedFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param ServerRequestInterface $request
  * @param RouterInterface $router
  */
 public function __construct(ServerRequestInterface $request, RouterInterface $router)
 {
     $this->request = $request;
     parent::__construct($this);
     $this->parameters = $this->parseIncomingParams();
     $this->parameters = array_merge($this->parameters, $this->request->getParsedBody(), $this->getParsedAttributes($request, $router), $this->getQueryParams(), $this->request->getUploadedFiles());
     $this->parsedBody = array_merge(parent::getParsedBody(), $this->parameters);
 }
开发者ID:atasciuc,项目名称:zend-expressive-validation,代码行数:12,代码来源:RequestValidator.php

示例2: data

 /**
  * {@inheritdoc}
  */
 public function data(ServerRequestInterface $request, Document $document)
 {
     $this->assertAdmin($request->getAttribute('actor'));
     $file = array_get($request->getUploadedFiles(), 'favicon');
     $tmpFile = tempnam($this->app->storagePath() . '/tmp', 'favicon');
     $file->moveTo($tmpFile);
     $extension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
     if ($extension !== 'ico') {
         $manager = new ImageManager();
         $encodedImage = $manager->make($tmpFile)->resize(64, 64, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->encode('png');
         file_put_contents($tmpFile, $encodedImage);
         $extension = 'png';
     }
     $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => new Filesystem(new Local($this->app->publicPath() . '/assets'))]);
     if (($path = $this->settings->get('favicon_path')) && $mount->has($file = "target://{$path}")) {
         $mount->delete($file);
     }
     $uploadName = 'favicon-' . Str::lower(Str::quickRandom(8)) . '.' . $extension;
     $mount->move('source://' . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
     $this->settings->set('favicon_path', $uploadName);
     return parent::data($request, $document);
 }
开发者ID:flarum,项目名称:core,代码行数:28,代码来源:UploadFaviconController.php

示例3: data

 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     $file = array_get($request->getUploadedFiles(), 'avatar');
     return $this->bus->dispatch(new UploadAvatar($id, $file, $actor));
 }
开发者ID:clops,项目名称:core,代码行数:10,代码来源:UploadAvatarController.php

示例4: _extractDataPSR7

 private function _extractDataPSR7(ServerRequestInterface $request = null, $name = '')
 {
     $method = $request->getMethod();
     $queryParams = $request->getQueryParams();
     if ('GET' === $method) {
         if ('' === $name) {
             return $queryParams;
         }
         // Don't submit GET requests if the form's name does not exist
         // in the request
         if (!isset($queryParams[$name])) {
             return;
         }
         return $queryParams[$name];
     }
     $serverParams = $request->getServerParams();
     $uploadedFiles = $request->getUploadedFiles();
     if ('' === $name) {
         return $this->mergeParamsAndUploadedFiles($serverParams, $uploadedFiles);
     }
     if (isset($serverParams[$name]) || isset($uploadedFiles[$name])) {
         $default = null;
         $params = isset($serverParams[$name]) ? $serverParams[$name] : null;
         $files = isset($uploadedFiles[$name]) ? $uploadedFiles[$name] : null;
         return $this->mergeParamsAndUploadedFiles($params, $files);
     }
     // Don't submit the form if it is not present in the request
     return;
 }
开发者ID:pugx,项目名称:bindto,代码行数:29,代码来源:PSR7RequestTrait.php

示例5: convertRequestFromPsr7

 /**
  * Converts a PSR-7 request into an OAuth2 request.
  *
  * @param ServerRequestInterface $psrRequest
  * @return Request
  */
 public static function convertRequestFromPsr7(ServerRequestInterface $psrRequest)
 {
     $headers = [];
     foreach ($psrRequest->getHeaders() as $header => $value) {
         $headers[$header] = implode(';', $value);
     }
     return new Request($psrRequest->getQueryParams(), is_array($psrRequest->getParsedBody()) ? $psrRequest->getParsedBody() : [], $psrRequest->getAttributes(), $psrRequest->getCookieParams(), self::getFiles($psrRequest->getUploadedFiles()), $psrRequest->getServerParams(), $psrRequest->getBody()->__toString(), $headers);
 }
开发者ID:tonis-io,项目名称:oauth2,代码行数:14,代码来源:Util.php

示例6: updateValuesFromRequest

 /**
  * Assign form values from request
  */
 protected function updateValuesFromRequest()
 {
     $data = $this->getRequest()->isPost() ? $this->getRequest()->getPost() : $this->getRequest()->getQuery();
     if (isset($_FILES)) {
         $data = array_merge($data, $this->request->getUploadedFiles());
     }
     $this->setValues($data);
 }
开发者ID:slickframework,项目名称:form,代码行数:11,代码来源:Form.php

示例7: createRequest

 /**
  * {@inheritdoc}
  */
 public function createRequest(ServerRequestInterface $psrRequest)
 {
     $parsedBody = $psrRequest->getParsedBody();
     $parsedBody = is_array($parsedBody) ? $parsedBody : array();
     $request = new Request($psrRequest->getQueryParams(), $parsedBody, $psrRequest->getAttributes(), $psrRequest->getCookieParams(), $this->getFiles($psrRequest->getUploadedFiles()), $psrRequest->getServerParams(), $psrRequest->getBody()->__toString());
     $request->headers->replace($psrRequest->getHeaders());
     return $request;
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:11,代码来源:HttpFoundationFactory.php

示例8: onPost

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * @return ResponseInterface
  */
 public function onPost(ServerRequestInterface $request, ResponseInterface $response)
 {
     /** @var UploadedFile $upload */
     $uploaded = $request->getUploadedFiles();
     $upload = $uploaded['up'][0];
     $viewData = $this->responder->getViewData()->setData('isUploaded', true)->setData('dump', print_r($uploaded, true))->setData('upload', $upload)->setData('error_code', $upload->getError());
     return $this->viewer->__invoke($request, $response, $viewData);
     // callable
 }
开发者ID:asaokamei,项目名称:slim-tuum,代码行数:14,代码来源:UploadController.php

示例9: toZend

 /**
  * Convert a PSR-7 ServerRequest to a Zend\Http server-side request.
  *
  * @param ServerRequestInterface $psr7Request
  * @param bool $shallow Whether or not to convert without body/file
  *     parameters; defaults to false, meaning a fully populated request
  *     is returned.
  * @return Zend\Request
  */
 public static function toZend(ServerRequestInterface $psr7Request, $shallow = false)
 {
     if ($shallow) {
         return new Zend\Request($psr7Request->getMethod(), $psr7Request->getUri(), $psr7Request->getHeaders(), $psr7Request->getCookieParams(), $psr7Request->getQueryParams(), [], [], $psr7Request->getServerParams());
     }
     $zendRequest = new Zend\Request($psr7Request->getMethod(), $psr7Request->getUri(), $psr7Request->getHeaders(), $psr7Request->getCookieParams(), $psr7Request->getQueryParams(), $psr7Request->getParsedBody() ?: [], self::convertUploadedFiles($psr7Request->getUploadedFiles()), $psr7Request->getServerParams());
     $zendRequest->setContent($psr7Request->getBody());
     return $zendRequest;
 }
开发者ID:MidnightDesign,项目名称:zend-psr7bridge,代码行数:18,代码来源:Psr7ServerRequest.php

示例10: resolveSources

 protected function resolveSources(ServerRequestInterface $request)
 {
     $original_data = ['get' => $request->getQueryParams(), 'post' => $request->getParsedBody(), 'file' => $request->getUploadedFiles(), 'cookie' => $request->getCookieParams(), 'uri' => $this->resolveUriSource($request)];
     foreach ($this->param_sources as $item => $source) {
         if (isset($original_data[$source][$item])) {
             $params[$item] = $original_data[$source][$item];
         }
     }
     return $params;
 }
开发者ID:bermlida,项目名称:module-extension,代码行数:10,代码来源:Route.php

示例11: isUpload

 public function isUpload(ServerRequestInterface $request)
 {
     $contentTypes = $request->getHeader('Content-Type');
     foreach ($contentTypes as $contentType) {
         if (false !== strpos($contentType, 'multipart/form-data')) {
             return count($request->getUploadedFiles()) > 0;
         }
     }
     return false;
 }
开发者ID:danielbragaalmeida,项目名称:extdirect,代码行数:10,代码来源:Router.php

示例12: loadFromPsr7

 /**
  * Load the form values from a PSR-7 ServerRequest.
  *
  * @param ServerRequestInterface $request
  *
  * @return self
  */
 public function loadFromPsr7(ServerRequestInterface $request)
 {
     if (strtolower($this->attr('method')) === 'post') {
         $values = $request->getParsedBody();
         $files = $request->getUploadedFiles();
         $values = array_replace_recursive($values, $files);
     } else {
         $values = $request->getQueryParams();
     }
     return $this->load($values);
 }
开发者ID:goBrabus,项目名称:form-manager,代码行数:18,代码来源:Form.php

示例13: __construct

 /**
  * Construct action request.
  *
  * @param \Psr\Http\Message\ServerRequestInterface $request Request to wrap.
  */
 public function __construct(\Psr\Http\Message\ServerRequestInterface $request)
 {
     parent::__construct($request->getBody());
     foreach ($request->getHeaders() as $name => $value) {
         $this->setHeader($name, $value);
     }
     $this->protocolVersion = $request->getProtocolVersion();
     $this->method = $request->getMethod();
     $this->requestTarget = $request->getRequestTarget();
     $this->uri = $request->getUri();
     $this->attributes = $request->getAttributes();
     $this->cookies = $request->getCookieParams();
     $this->data = $request->getParsedBody();
     $this->query = $request->getQueryParams();
     $this->server = $request->getServerParams();
     $this->files = $request->getUploadedFiles();
     if (isset($this->server['SCRIPT_NAME'])) {
         $this->attributes['basePath'] = dirname($this->server['SCRIPT_NAME']);
         $this->attributes['scriptName'] = basename($this->server['SCRIPT_NAME']);
     } else {
         $this->attributes['basePath'] = '/';
         $this->attributes['scriptName'] = 'index.php';
     }
     if (!isset($this->attributes['path'])) {
         $this->attributes['path'] = self::findPath($this);
     }
     if (!isset($this->attributes['rewrite'])) {
         $this->attributes['rewrite'] = false;
     }
     if (!isset($this->attributes['accepts'])) {
         $this->attributes['accepts'] = [];
         if (isset($this->server['HTTP_ACCEPT'])) {
             $contentTypes = explode(',', $this->server['HTTP_ACCEPT']);
             foreach ($contentTypes as $contentType) {
                 $contentType = explode(';', $contentType);
                 $this->attributes['accepts'][] = trim(strtolower($contentType[0]));
             }
         }
     }
     if (!isset($this->attributes['encodings'])) {
         $this->attributes['encodings'] = [];
         if (isset($this->server['HTTP_ACCEPT_ENCODING'])) {
             $acceptEncodings = explode(',', $this->server['HTTP_ACCEPT_ENCODING']);
             foreach ($acceptEncodings as $encoding) {
                 $this->attributes['encodings'][] = trim(strtolower($encoding));
             }
         }
     }
 }
开发者ID:jivoo,项目名称:http,代码行数:54,代码来源:ActionRequest.php

示例14: __invoke

 /**
  * Flatten all input from the request
  *
  * @param ServerRequestInterface $request
  *
  * @return array
  */
 public function __invoke(ServerRequestInterface $request)
 {
     $attrs = $request->getAttributes();
     $body = $request->getParsedBody();
     $cookies = $request->getCookieParams();
     $query = $request->getQueryParams();
     $uploads = $request->getUploadedFiles();
     if (empty($body)) {
         $body = [];
     } elseif (is_object($body)) {
         // Because the parsed body may also be represented as an object,
         // additional parsing is required. This is a bit dirty but works
         // very well for anonymous objects.
         $body = json_decode(json_encode($body), true);
     }
     // Order matters here! Important values go last!
     return array_replace($query, $body, $uploads, $cookies, $attrs);
 }
开发者ID:JasonBusse,项目名称:rest_scheduler,代码行数:25,代码来源:Input.php

示例15: createRequest

 /**
  * {@inheritdoc}
  */
 public function createRequest(ServerRequestInterface $psrRequest)
 {
     $server = array();
     $uri = $psrRequest->getUri();
     if ($uri instanceof UriInterface) {
         $server['SERVER_NAME'] = $uri->getHost();
         $server['SERVER_PORT'] = $uri->getPort();
         $server['REQUEST_URI'] = $uri->getPath();
         $server['QUERY_STRING'] = $uri->getQuery();
     }
     $server['REQUEST_METHOD'] = $psrRequest->getMethod();
     $server = array_replace($server, $psrRequest->getServerParams());
     $parsedBody = $psrRequest->getParsedBody();
     $parsedBody = is_array($parsedBody) ? $parsedBody : array();
     $request = new Request($psrRequest->getQueryParams(), $parsedBody, $psrRequest->getAttributes(), $psrRequest->getCookieParams(), $this->getFiles($psrRequest->getUploadedFiles()), $server, $psrRequest->getBody()->__toString());
     $request->headers->replace($psrRequest->getHeaders());
     return $request;
 }
开发者ID:symfony,项目名称:psr-http-message-bridge,代码行数:21,代码来源:HttpFoundationFactory.php


注:本文中的Psr\Http\Message\ServerRequestInterface::getUploadedFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。