本文整理汇总了PHP中UploadedFile::getClientOriginalName方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadedFile::getClientOriginalName方法的具体用法?PHP UploadedFile::getClientOriginalName怎么用?PHP UploadedFile::getClientOriginalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadedFile
的用法示例。
在下文中一共展示了UploadedFile::getClientOriginalName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: s3Upload
/**
* Upload file to Amazon s3
*
* @param UploadedFile $file
* @param String $subdirectory
* @param String $type
* @return Array $uploadedFile
*/
private function s3Upload($file, $subdirectory, $type)
{
$client_original_name = $file->getClientOriginalName();
$fileName = time() . '_' . $client_original_name;
$destinationPath = 'uploads/' . $subdirectory;
$path = $destinationPath . '/' . $fileName;
$image = Image::make($file->getRealPath());
switch ($type) {
case 'profile_photo':
$image->fit(128, 128, function ($constraint) {
$constraint->upsize();
});
break;
case 'profile_cover':
$image->resize(1440, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
break;
}
$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, 'type' => $type];
return $uploadedFile;
}