當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UploadedFile::getRealPath方法代碼示例

本文整理匯總了PHP中UploadedFile::getRealPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadedFile::getRealPath方法的具體用法?PHP UploadedFile::getRealPath怎麽用?PHP UploadedFile::getRealPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UploadedFile的用法示例。


在下文中一共展示了UploadedFile::getRealPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: resizeExact

 /**
  * Resize an image to an exact width and height.
  *
  * @param  UploadedFile $file
  * @param  string $width - The image's new width.
  * @param  string $height - The image's new height.
  * @return Imagine\Image
  */
 protected function resizeExact($file, $width, $height)
 {
     return $this->imagine->open($file->getRealPath())->resize(new Box($width, $height));
 }
開發者ID:jaymondigo,項目名稱:custommade,代碼行數:12,代碼來源:Resizer.php

示例2: s3Upload

 /**
  * Upload file to Amazon s3
  *
  * @param  UploadedFile $file
  * @param  String $subdirectory
  * @return Array $uploadedFile
  */
 private function s3Upload($file, $subdirectory)
 {
     $client_original_name = $file->getClientOriginalName();
     $fileName = time() . '_' . $client_original_name;
     $destinationPath = 'uploads/' . $subdirectory;
     $path = $destinationPath . '/' . $fileName;
     $image = Image::make($file->getRealPath());
     $image->resize(600, null, function ($constraint) {
         $constraint->aspectRatio();
         $constraint->upsize();
     });
     $stream = $image->stream();
     $s3 = Storage::disk('s3');
     $s3->put($path, $stream->__toString(), 'public');
     $client = $s3->getDriver()->getAdapter()->getClient();
     $public_url = $client->getObjectUrl(env('S3_BUCKET'), $path);
     $original_name = pathinfo($client_original_name, PATHINFO_FILENAME);
     $uploadedFile = ['original_name' => $original_name, 'file_name' => $fileName, 'public_url' => $public_url];
     return $uploadedFile;
 }
開發者ID:realnerdo,項目名稱:blog,代碼行數:27,代碼來源:ArticlesController.php


注:本文中的UploadedFile::getRealPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。