當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。