Laravel Livewire Multiple Files Upload API with Loading and Preview Image

Laravel Livewire Multiple Files Upload API with Loading and Preview Image

In this tutorial, you'll learn to use the Laravel Livewire Multiple Files Upload API with Loading and Preview Image and also a video tutorial

A newer version 1.2.0 is added to Laravel Livewire which consists of File Uploads Components. Before this feature, you have manually use create an event and pass the base64 data to the livewire component.

But in this newer version there is no need to do those steps as you can use WithFileUploads trait which will implicitly create a file object for you and you can also use this to validate, store and also display the preview of the selected image in the template itself.

Note

If you are looking for uploading files using Javascript Invocation in Livewire than you visit this post.

Table of Content

Create New Laravel Project

Run below command to create a new Laravel Project.

composer create-project --prefer-dist laravel/laravel my_new_laravel

After successful installation navigates inside the project through the terminal.

Install and Configure Livewire

After Laravel Project is successfully installed run composer require livewire/livewire to install Livewire.

After this the next step is to publish the config and assets base URL file through which we can specify a custom assets path for livewire package.

php artisan vendor:publish --tag=livewire:config

The above command will publish a config file livewire.php in the config folder inside the project root.

php artisan vendor:publish --tag=livewire:assets

The above command will publish assets for livewire at the path public/vendor folder.

The Livewire official docs recommend adding post-autoload-dump into composer.json inside scripts as shown below.

{
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan vendor:publish --force --tag=livewire:assets --ansi"
        ]
    }
}

Include Livewire Assets into Blade Template

Now you can start developing your project and the first thing you must do is to create a base template that contains livewire javascript assets.

For this let us first create a route.

Route::get('/', function () {
    return view('base');
});

laravel laravel livewire php laravel web development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire PHP Developer - Best PHP Web Frameworks for Web Development

Hire our Laravel, CodeIgniter, YII, Zend, Cake PHP, Core PHP developers for your custom web development projects. Choose best PHP Web Frameworks & get satisfactory results.

Laravel Development Company| Hire Laravel Web Developers-SISGAIN

SISGAIN offers custom Laravel Website Development Services across the globe. To get the outstanding laravel web development services,hire the professional laravel developers from us.

Hire Dedicated Core PHP Developers | Hire PHP Developer

Our dedicated PHP developers write bug-free and optimized code for custom PHP web development projects. Hire us today and get satisfactory results.

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...

PHP Website Development

Skenix Infotech is a leading PHP Web Development Company that helps companies get results with industry best practices. Get affordable PHP Development Services.