20 lines
553 B
PHP
20 lines
553 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services;
|
||
|
|
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
class UploadService
|
||
|
|
{
|
||
|
|
public function storageFile($file)
|
||
|
|
{
|
||
|
|
$folder_name = "uploads/images/avatars/" . date("Ym/d", time());
|
||
|
|
$upload_path = storage_path($folder_name) ;
|
||
|
|
$extension = strtolower($file->getClientOriginalExtension()) ?: 'png';
|
||
|
|
$file_prefix = '';
|
||
|
|
$filename = $file_prefix . '_' . time() . '_' . Str::random(10) . '.' . $extension;
|
||
|
|
$file->move($upload_path, $filename);
|
||
|
|
return $upload_path.'/'.$filename;
|
||
|
|
}
|
||
|
|
}
|