Example of File upload in nasirkhan/laravel-starter

File composer.json (link to Github)
{
    //
    "require": {
        "php": "^7.3|^8.0",
        //
        "spatie/laravel-medialibrary": "^8.10"
    },
    //
}
File resources/views/frontend/users/profileEdit.blade.php (link to Github)
//
                        {{ html()->modelForm($userprofile, 'PATCH', route('frontend.users.profileUpdate', $$module_name_singular->id))->class('form-horizontal')->acceptsFiles()->open() }}
                        //
                            <div class="col-md-5">
                                <div class="form-group">
                                    <label for="file-multiple-input">Click here to update photo</label>
                                    <input id="file-multiple-input" name="avatar" multiple="" type="file" class="form-control-file">
                                </div>
                            </div>
                        //
                    {{ html()->closeModelForm() }}
//
File app/Models/User.php (link to Github)
use App\Models\Traits\HasHashedMediaTrait;
use Spatie\MediaLibrary\HasMedia;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements HasMedia
{
    use HasHashedMediaTrait;
    //
}
File app/Models/Traits/HasHashedMediaTrait.php (link to Github)
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\FileAdder;

trait HasHashedMediaTrait
{
    use InteractsWithMedia {
        InteractsWithMedia::addMedia as parentAddMedia;
    }

    public function addMedia($file): FileAdder
    {
        return $this->parentAddMedia($file)->usingFileName($file->hashName());
    }
}
File app/Http/Controllers/Frontend/UserController.php (link to Github)
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class UserController extends Controller
{
    public function profileUpdate(Request $request, $id)
    {
        //
        if ($request->hasFile('avatar')) {
            if ($$module_name_singular->getMedia($module_name)->first()) {
                $$module_name_singular->getMedia($module_name)->first()->delete();
            }

            $media = $$module_name_singular->addMedia($request->file('avatar'))->toMediaCollection($module_name);

            $$module_name_singular->avatar = $media->getUrl();

            $$module_name_singular->save();
        }
        //
    }
    //
}

Additional resources on File upload: