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


PHP IRequest::getFile方法代码示例

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


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

示例1: handleUpload

 public function handleUpload()
 {
     $file = $this->httpRequest->getFile('Filedata');
     if ($file->isOk()) {
         $this->onUpload($file, $this->httpRequest->getPost());
     } else {
         $this->onError($file->getError());
     }
     $this->presenter->terminate();
 }
开发者ID:peterzadori,项目名称:movi,代码行数:10,代码来源:Uploadify.php

示例2: handleSaveImage

 /**
  * it's not only handleGallerySaveImage now. We use it for save texy images too
  */
 public function handleSaveImage()
 {
     if ($this->mainManager instanceof MagicManager && $this->mainManager->isGallery()) {
         $folder = $this->mainManager->getGalleryFolder();
     } else {
         $this->error();
     }
     if ($folder == '') {
         $folder = 'misc';
     }
     $file = $this->httpRequest->getFile('Filedata');
     if ($file && $file->isOk() && $this->detailObject) {
         // Save ...
         $year = date('Y');
         $month = date('m');
         $namespace = "{$folder}/{$year}/{$month}";
         $this->imageStorage->setNamespace($namespace);
         $image = $this->imageStorage->save($file->getContents(), $file->getName());
         $filename = pathinfo($image->getFile(), PATHINFO_BASENAME);
         $size = $image->getSize();
         // Prepare thumbnail
         $this->imgPipe->setNamespace($namespace);
         $this->imgPipe->request($filename, '100x100', 'exact');
         // Save to database
         $this->mainManager->addGalleryImage($filename, $namespace, $size->getWidth(), $size->getHeight(), $file->getContentType(), $this->detailObject->id);
         $response = ['status' => '1', 'height' => $size->getHeight(), 'width' => $size->getWidth(), 'mime' => $file->getContentType()];
     } else {
         $response = ['status' => '0', 'error' => 'Error while uploading file', 'code' => 500];
     }
     $this->sendJson($response);
 }
开发者ID:aprila,项目名称:quick,代码行数:34,代码来源:MagicPresenter.php

示例3: handleSaveImage

 /**
  * TODO: refactor use Aprila/Brick/ImageManager
  */
 public function handleSaveImage()
 {
     $this->imageStorage->setNamespace("texy");
     $onlinePath = 'texy/';
     $response = array();
     /** @var \Nette\Http\FileUpload $file */
     if ($file = $this->httpRequest->getFile('file')) {
         $filename = uniqid() . '.' . (pathinfo($file->name, PATHINFO_EXTENSION) ?: 'png');
         $image = $this->imageStorage->save($file->getContents(), $filename);
         $returnPath = pathinfo($image->file, PATHINFO_BASENAME);
         if (FALSE) {
             // $this->someManager->assignImageToObject($this->object->id, $returnPath, "texy");
         }
         $response['filename'] = $onlinePath . pathinfo($image->file, PATHINFO_BASENAME);
     } else {
         $response['error'] = 'Error while uploading file';
     }
     $this->sendJson($response);
 }
开发者ID:Aprila,项目名称:laboratory,代码行数:22,代码来源:TexyExamplePresenter.php

示例4: handleSaveImage

 public function handleSaveImage()
 {
     $file = $this->httpRequest->getFile('Filedata');
     if ($file && $file->isOk()) {
         $year = date('Y');
         $month = date('m');
         $namespace = "project/{$year}/{$month}";
         $this->imageStorage->setNamespace($namespace);
         $tempFilename = uniqid() . '.' . (pathinfo($file->getName(), PATHINFO_EXTENSION) ?: 'jpg');
         $image = $this->imageStorage->save($file->getContents(), $tempFilename);
         $size = $image->getSize();
         $colorInfo = $this->getImageColorInfo($image->getFile());
         $filename = pathinfo($image->getFile(), PATHINFO_BASENAME);
         $this->addImage($filename, $namespace, $size->getWidth(), $size->getHeight(), $colorInfo, $file->getName(), $file->getContentType());
         // Prepare thumbnail
         $this->imgPipe->setNamespace($namespace);
         $this->imgPipe->request($filename, '100x100', 'exact');
         $response = ['status' => '1', 'height' => $size->getHeight(), 'width' => $size->getWidth(), 'mime' => $file->getContentType()];
     } else {
         $response = ['status' => '0', 'error' => 'Error while uploading file', 'code' => 500];
     }
     $this->sendJson($response);
 }
开发者ID:Aprila,项目名称:laboratory,代码行数:23,代码来源:FormExamplePresenter.php

示例5: getFile

 /**
  * @inheritdoc
  */
 public function getFile($key)
 {
     return $this->current->getFile($key);
 }
开发者ID:Kdyby,项目名称:RequestStack,代码行数:7,代码来源:RequestStack.php


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