本文整理汇总了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());
}
示例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;
}