Subscribe to PHP Freaks RSS

Laravel News: Uploading Avatar Images with Spatie’s Media Library

syndicated from www.phpdeveloper.org on March 26, 2018

On the Laravel News site, there's a new tutorial posted showing how you can use the Spatie Media Library package to help with the file uploads in your Laravel-based application to upload avatars for your users.

By default, the Laravel registration form contains only the name, email, and password, but often it’s useful to allow the user to upload a photo or an avatar. In this tutorial we will show you an easy way to add it, using [Spatie’s Media Library](https://github.com/spatie/laravel-medialibrary) package.

The remainder of the tutorial then breaks the implementation down into three steps:

  • Change the User Registration Form (to include the "avatar" field)
  • Upload and Store with the Media Library (installing the relation and changing the models)
  • Show an Avatar Thumbnail in the Top Navigation (using the package to resize the image)

Each step in the process includes the code or commands required to complete it. There are also several screenshots to help ensure you have the right information stored in your database.