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


PHP Request::getFiles方法代码示例

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


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

示例1: fromZend

 /**
  * Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
  *
  * @param  ZendRequest $zendRequest
  * @return ServerRequest
  */
 public static function fromZend(ZendRequest $zendRequest)
 {
     $body = new Stream('php://memory', 'wb+');
     $body->write($zendRequest->getContent());
     $headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
     $query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
     $post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
     $files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
     $request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
     $request = $request->withQueryParams($query);
     return $request->withParsedBody($post);
 }
开发者ID:MidnightDesign,项目名称:zend-psr7bridge,代码行数:18,代码来源:Psr7ServerRequest.php

示例2: create

 public static function create(HttpRequest $request)
 {
     $queryParams = $request->getQuery()->toArray();
     $postParams = $request->getPost()->toArray();
     $files = $request->getFiles()->toArray();
     $cookies = ($c = $request->getCookie()) ? [$c] : [];
     return new OAuth2Request($queryParams, $postParams, [], $cookies, $files, $_SERVER);
 }
开发者ID:eschwartz,项目名称:ZfAuth,代码行数:8,代码来源:OAuth2RequestFactory.php

示例3: testParameterRetrievalDefaultValue

 public function testParameterRetrievalDefaultValue()
 {
     $request = new Request();
     $p = new \Zend\Stdlib\Parameters(array('foo' => 'bar'));
     $request->setQuery($p);
     $request->setPost($p);
     $request->setFiles($p);
     $default = 15;
     $this->assertSame($default, $request->getQuery('baz', $default));
     $this->assertSame($default, $request->getPost('baz', $default));
     $this->assertSame($default, $request->getFiles('baz', $default));
     $this->assertSame($default, $request->getHeaders('baz', $default));
     $this->assertSame($default, $request->getHeader('baz', $default));
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:14,代码来源:RequestTest.php

示例4: uploadFile

 /**
  * @param Request $request
  * @param int $buildingId
  * @return bool
  */
 public function uploadFile($request, $buildingId)
 {
     try {
         /** @var \DDD\Dao\ApartmentGroup\BuildingDetails $buildingDetailsDao */
         $buildingDetailsDao = $this->getServiceLocator()->get('dao_apartment_group_building_details');
         $files = $request->getFiles();
         $file = $files['map_attachment'];
         $attachmentExtension = pathinfo($file['name'], PATHINFO_EXTENSION);
         // file attached
         if ($file['error'] !== 4) {
             if ($file['error'] !== 0) {
                 throw new \Exception('File upload failed.');
             }
             if ($file['size'] > self::ATTACHMENT_SIZE * 1024 * 1024) {
                 throw new \Exception('File size is too big.');
             }
             if (in_array($attachmentExtension, ['php', 'phtml', 'html', 'js'])) {
                 throw new \Exception('Invalid file format.');
             }
             $folderPath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_IMAGES_ROOT . DirectoryStructure::FS_IMAGES_BUILDING . $buildingId . '/map';
             if (!is_dir($folderPath)) {
                 if (!mkdir($folderPath, 0775, true)) {
                     throw new \Exception('Upload failed. Can\'t create directory.');
                 }
             }
             $oldData = $buildingDetailsDao->fetchOne(['apartment_group_id' => $buildingId], ['map_attachment']);
             $filename = 'ki_map_' . $buildingId . '_' . time();
             $filename = $filename . '.' . $attachmentExtension;
             $fullPath = $folderPath . '/' . $filename;
             // remove old uploaded file
             if ($oldData['map_attachment']) {
                 $oldFile = $folderPath . '/' . $oldData['map_attachment'];
                 @unlink($oldFile);
             }
             Files::moveFile($file['tmp_name'], $fullPath);
             $buildingDetailsDao->save(['map_attachment' => $filename], ['apartment_group_id' => $buildingId]);
             return true;
         }
     } catch (\Exception $ex) {
         return false;
     }
     return false;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:48,代码来源:Building.php

示例5: authenticate

 /**
  * Attempt to authenticate the current request.
  *
  * @param Request $request
  * @param Response $response
  * @param MvcAuthEvent $mvcAuthEvent
  * @return false|Identity\IdentityInterface False on failure, IdentityInterface
  *     otherwise
  */
 public function authenticate(Request $request, Response $response, MvcAuthEvent $mvcAuthEvent)
 {
     $oauth2request = new OAuth2Request($request->getQuery()->toArray(), $request->getPost()->toArray(), [], $request->getCookie() ? $request->getCookie()->getArrayCopy() : [], $request->getFiles() ? $request->getFiles()->toArray() : [], method_exists($request, 'getServer') ? $request->getServer()->toArray() : $_SERVER, $request->getContent(), $request->getHeaders()->toArray());
     // Failure to validate
     if (!$this->oauth2Server->verifyResourceRequest($oauth2request)) {
         $oauth2Response = $this->oauth2Server->getResponse();
         $status = $oauth2Response->getStatusCode();
         // 401 or 403 mean invalid credentials or unauthorized scopes; report those.
         if (in_array($status, [401, 403], true) && null !== $oauth2Response->getParameter('error')) {
             return $this->mergeOAuth2Response($status, $response, $oauth2Response);
         }
         // Merge in any headers; typically sets a WWW-Authenticate header.
         $this->mergeOAuth2ResponseHeaders($response, $oauth2Response->getHttpHeaders());
         // Otherwise, no credentials were present at all, so we just return a guest identity.
         return new Identity\GuestIdentity();
     }
     $token = $this->oauth2Server->getAccessTokenData($oauth2request);
     $identity = new Identity\AuthenticatedIdentity($token);
     $identity->setName($token['user_id']);
     return $identity;
 }
开发者ID:nuxwin,项目名称:zf-mvc-auth,代码行数:30,代码来源:OAuth2Adapter.php

示例6: processFormRequest

 /**
  * @param Request       $request
  * @param FormInterface $form
  * @param Content       $content
  */
 private function processFormRequest(Request $request, FormInterface $form, Content $content)
 {
     if ($request->isPost()) {
         $data = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $this->processFormData($form, $content, $data);
     }
 }
开发者ID:samsonasik,项目名称:unnamed,代码行数:12,代码来源:ContentController.php

示例7: hasUploadedFiles

 /**
  * @param HttpRequest $files
  * @return bool
  */
 public static function hasUploadedFiles(HttpRequest $request)
 {
     $files = $request->getFiles()->toArray();
     return (bool) ArrayUtils::filterRecursive($files, function ($value) {
         return $value && $value !== UPLOAD_ERR_NO_FILE;
     }, true);
 }
开发者ID:coolms,项目名称:common,代码行数:11,代码来源:AbstractCrudController.php


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