DEV Community

Cover image for Laravel File Upload with Progress Bar Example
Msh Sayket
Msh Sayket

Posted on

Laravel File Upload with Progress Bar Example

In this post, we will learn how to ajax image upload with progress bar in laravel application. Laravel File Upload with Progress Bar

You always did file uploading in a normal way, and you can do it easily. But when you have a large amount of file size, it takes time to upload on a server. Maybe you can’t reduce the time to upload a file or image, but you can display a progress bar with a percentage so the client can understand how much time is left to upload a file.

In this tutorial, we will create two routes with the FileController controller file. When you click on the submit button, fire the jQuery AJAX method, and the upload of the image will show you a progress bar. Let’s follow the steps below to do this example.

Laravel File Upload with Progress Bar Example

Step 1: Install Laravel 11

First of all, we need to get a fresh Laravel 11 version application using the command below because we are starting from scratch. So, open your terminal or command prompt and run the command below:

composer create-project laravel/laravel example-app
Enter fullscreen mode Exit fullscreen mode

Step 2: Create Routes

In the first step, we will add two new routes. One for displaying the view, and we will write jQuery code in the view file. In the second step, we will create a POST route for file upload.

routes/web.php

<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\FileController;

Route::controller(FileController::class)->group(function(){
    Route::get('file-upload', 'index');
    Route::post('file-upload', 'store')->name('file.upload');
});
Enter fullscreen mode Exit fullscreen mode

Read Full Tutorials
Read Also: How to Install Bootstrap 5 in Laravel 12 with Vite

Top comments (0)