本文整理匯總了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));
}
示例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;
}