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


PHP Request::getFile方法代码示例

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


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

示例1: testRequestAllowsSettingOfParameterContainer

 public function testRequestAllowsSettingOfParameterContainer()
 {
     $request = new Request();
     $p = new \Zend\Stdlib\Parameters();
     $request->setQuery($p);
     $request->setPost($p);
     $request->setFile($p);
     $request->setServer($p);
     $request->setEnv($p);
     $this->assertSame($p, $request->getQuery());
     $this->assertSame($p, $request->getPost());
     $this->assertSame($p, $request->getFile());
     $this->assertSame($p, $request->getServer());
     $this->assertSame($p, $request->getEnv());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:15,代码来源:RequestTest.php

示例2: uploadSlideShow

 /**
  * Uploads the specified Slide show the the server
  *
  * @param Zend\Service\SlideShare\SlideShow $ss The slide show object representing the slide show to upload
  * @param boolean $makeSourcePublic Determines if the slide show's source file is public or not upon upload
  * @throws \Zend\Service\SlideShare\Exception
  * @return Zend\Service\SlideShare\SlideShow The passed Slide show object, with the new assigned ID provided
  */
 public function uploadSlideShow(SlideShow $ss, $makeSourcePublic = true)
 {
     $timestamp = time();
     $params = array('api_key' => $this->getApiKey(), 'ts' => $timestamp, 'hash' => sha1($this->getSharedSecret() . $timestamp), 'username' => $this->getUserName(), 'password' => $this->getPassword(), 'slideshow_title' => $ss->getTitle(), 'make_src_public' => $makeSourcePublic ? 'Y' : 'N');
     $description = $ss->getDescription();
     $tags = $ss->getTags();
     $filename = $ss->getFilename();
     if (!file_exists($filename) || !is_readable($filename)) {
         throw new Exception\InvalidArgumentException("Specified Slideshow for upload not found or unreadable");
     }
     if (!empty($description)) {
         $params['slideshow_description'] = $description;
     } else {
         $params['slideshow_description'] = "";
     }
     if (!empty($tags)) {
         $tmp = array();
         foreach ($tags as $tag) {
             $tmp[] = "\"{$tag}\"";
         }
         $params['slideshow_tags'] = implode(' ', $tmp);
     } else {
         $params['slideshow_tags'] = "";
     }
     $httpClient = $this->getHttpClient();
     $request = new HttpRequest();
     $request->setUri(self::SERVICE_UPLOAD_URI);
     $request->getPost()->fromArray($params);
     $request->setMethod(HttpRequest::METHOD_POST);
     $request->getFile()->set('slideshow_srcfile', $filename);
     $httpClient->setEncType(HttpClient::ENC_URLENCODED);
     try {
         $response = $httpClient->send();
     } catch (HttpException\ExceptionInterface $e) {
         throw new HttpException\RuntimeException("Service Request Failed: {$e->getMessage()}", 0, $e);
     }
     $sxe = simplexml_load_string($response->getBody());
     if ($sxe->getName() == "SlideShareServiceError") {
         $message = (string) $sxe->Message[0];
         list($code, $error_str) = explode(':', $message);
         throw new Exception\RuntimeException(trim($error_str), $code);
     }
     if (!$sxe->getName() == "SlideShowUploaded") {
         throw new Exception\RuntimeException("Unknown XML Respons Received");
     }
     $ss->setId((int) (string) $sxe->SlideShowID);
     return $ss;
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:56,代码来源:SlideShare.php


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