本文整理匯總了PHP中UploadedFile::getClientOriginalExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP UploadedFile::getClientOriginalExtension方法的具體用法?PHP UploadedFile::getClientOriginalExtension怎麽用?PHP UploadedFile::getClientOriginalExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UploadedFile
的用法示例。
在下文中一共展示了UploadedFile::getClientOriginalExtension方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveFile
protected function saveFile(UploadedFile $file)
{
$upload_dir = public_path('uploads/');
$file_name = 'file-' . date('dmY-His') . '.' . $file->getClientOriginalExtension();
try {
if ($file->move($upload_dir, $file_name)) {
return $file_name;
} else {
return false;
}
} catch (\Exception $ex) {
return abort(500, $ex->getMessage());
}
}
示例2: buildImage
/**
* Build the image.
*
* @param string $slug
* @param UploadedFile $image
*
* @return string
*/
protected function buildImage($slug, $image)
{
$filePath = '/uploads/' . $slug . '.' . $image->getClientOriginalExtension();
Image::make($image)->save(public_path($filePath));
return $filePath;
}
示例3: upload
/**
* @param UploadedFile $file
*
* @param null $filename
* @return null|string
*/
private function upload(UploadedFile $file, $filename = null)
{
if ($file && $file->isValid()) {
if (!Storage::exists('page_image')) {
Storage::makeDirectory('page_image');
}
if ($filename === null) {
$filename = $this->getUniqueName('page_image', $file->getClientOriginalExtension());
}
$file->move('page_image', $filename);
return $filename;
}
return null;
}