Datei-Upload mit Fortschrittsbalken mit Vanilla JavaScript in Laravel 9

In diesem Handbuch lernen wir Laravel 9 Upload Image with Progress Bar mit Vanilla JavaScript kennen. Unter diesem Beitrag zeigen wir Ihnen ein einfaches Beispiel für den Upload von Laravel 9-Dateien mit Bootstrap 5 Progress Bar unter Verwendung von Vanilla JavaScript.

Um einen Datei-Upload mit Fortschrittsbalken mit Vanille-JavaScript in Laravel 9 durchzuführen, folgen wir diesen Schritten.

1 : Installieren Sie Laravel 9 Framework

composer create-project laravel/laravel javascript_file_upload

2 : Erstellen Sie einen Dateicontroller in Laravel 9

php artisan make:controller FileController



namespace App\Http\Controllers;

use Illuminate\Http\Request;

class FileController extends Controller
    function index()
        return view('javascript_file_upload');

    function upload(Request $request)
        $file_name = time() . '.' . request()->sample_image->getClientOriginalExtension();

        request()->sample_image->move(public_path('images'), $file_name);

        $image_path = asset('images/'. $file_name);

        return response()->json(['image_path'=>$image_path]);

3 : Blade-View-Datei erstellen


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Laravel 9 JavaScript File Upload with Progress Bar</title>
    <link href="" rel="stylesheet">
    <div class="container mt-5" style="max-width: 900px">
        <div class="alert alert-primary mb-4 text-center">
           <h2 class="display-6">Laravel 9 JavaScript File Upload with Progress Bar</h2>
        <div class="card">
            <div class="card-header">Select File</div>
            <div class="card-body">
                <table class="table">
                        <td width="50%" align="right"><b>Select File</b></td>
                        <td width="50%">
                            <input type="file" id="select_file" />
        <br />
        <div class="progress" id="progress_bar" style="display:none;height:50px; line-height: 50px;">

            <div class="progress-bar" id="progress_bar_process" role="progressbar" style="width:0%;">0%</div>


        <div id="uploaded_image" class="row mt-5"></div>


var file_element = document.getElementById('select_file');

var progress_bar = document.getElementById('progress_bar');

var progress_bar_process = document.getElementById('progress_bar_process');

var uploaded_image = document.getElementById('uploaded_image');

file_element.onchange = function(){

    if(!['image/jpeg', 'image/png'].includes(file_element.files[0].type))
        uploaded_image.innerHTML = '<div class="alert alert-danger">Selected File must be .jpg or .png Only</div>';

        file_element.value = '';
        var form_data = new FormData();

        form_data.append('sample_image', file_element.files[0]);

        form_data.append('_token', document.getElementsByName('_token')[0].value); = 'block';

        var ajax_request = new XMLHttpRequest();"POST", "{{ route('upload_file.upload') }}");

        ajax_request.upload.addEventListener('progress', function(event){

            var percent_completed = Math.round((event.loaded / * 100);

   = percent_completed + '%';

            progress_bar_process.innerHTML = percent_completed + '% completed';


        ajax_request.addEventListener('load', function(event){

            var file_data = JSON.parse(;

            uploaded_image.innerHTML = '<div class="alert alert-success">Files Uploaded Successfully</div><img src="'+file_data.image_path+'" class="img-fluid img-thumbnail" />';

            file_element.value = '';






4 : Legen Sie die Routen der Controller-Methode fest



use Illuminate\Support\Facades\Route;

use App\Http\Controllers\FileController;

| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

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

    Route::get('upload_file', 'index');

    Route::post('upload_file/upload', 'upload')->name('upload_file.upload');

5 : Führen Sie die Laravel 9-Anwendung aus

php artisan serve

What is GEEK

Buddha Community

I am Developer


Multiple File Upload in Laravel 7, 6

in this post, i will show you easy steps for multiple file upload in laravel 7, 6.

As well as how to validate file type, size before uploading to database in laravel.

Laravel 7/6 Multiple File Upload

You can easily upload multiple file with validation in laravel application using the following steps:

  1. Download Laravel Fresh New Setup
  2. Setup Database Credentials
  3. Generate Migration & Model For File
  4. Make Route For File uploading
  5. Create File Controller & Methods
  6. Create Multiple File Blade View
  7. Run Development Server

#laravel multiple file upload validation #multiple file upload in laravel 7 #multiple file upload in laravel 6 #upload multiple files laravel 7 #upload multiple files in laravel 6 #upload multiple files php laravel

I am Developer


Ajax Multiple Image Upload with Progress bar with jQuery in Laravel

In this post, i will show you, how you can upload multiple file with progress bar in laravel using jQuery ajax.

So follow below given steps to create ajax multiple image upload with progress bar with jquery and laravel php.

Multiple File Upload with Progress bar Using jQuery and Laravel PHP

Now follow the below given simple and easy step to upload multiple file with progress bar in laravel using jQuery ajax:

  • Step 1: Download Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration & Model
  • Step 4: Add Routes For Multiple File Upload
  • Step 5: Create Controller by Artisan
  • Step 6: Create Blade View
  • Step 7: Run Development Server

#multiple file upload with progress bar using jquery and laravel #laravel multiple file upload ajax with progress bar #how to upload multiple images with progress bar in laravel #laravel 7 multiple image upload example #image upload with progress bar laravel #laravel multiple image upload ajax

I am Developer


Laravel 7/6 Image Upload Example Tutorial

Laravel image upload example tutorial. Here, i will show you how to upload image in laravel 7/6 with preview and validation.

Before store image into db and folder, you can validate uploaded image by using laravel validation rules. as well as you can show preview of uploaded image in laravel.

Image Upload In Laravel 7/6 with Validation

Image upload in laravel 7/6 with preview and validation. And storage image into folder and MySQL database by using the below steps:

Install Laravel Fresh App
Setup Database Details
Generate Image Migration & Model
Create Image Upload Route
Create Image Controller
Create Image Upload and Preview Blade View
Start Development Server

#laravel 7 image upload example #laravel upload image to database #how to insert image into database in laravel #laravel upload image to storage #laravel image upload tutorial #image upload in laravel 7/6

I am Developer


Laravel 7 File Upload Via API Example From Scratch

Laravel 7 file/image upload via API using postman example tutorial. Here, you will learn how to upload files/images via API using postman in laravel app.

As well as you can upload images via API using postman in laravel apps and also you can upload images via api using ajax in laravel apps.

If you work with laravel apis and want to upload files or images using postman or ajax. And also want to validate files or images before uploading to server via API or ajax in laravel.

So this tutorial will guide you step by step on how to upload file vie API using postman and ajax in laravel with validation.

Laravel Image Upload Via API Using Postman Example


Follow the below given following steps and upload file vie apis using postman with validation in laravel apps:

  • Step 1: Install Laravel New App
  • Step 2: Add Database Credentials
  • Step 3: Generate Migration & Model
  • Step 4: Create Routes For File
  • Step 5: Generate Controller by Artisan
  • Step 6: Run Development Server
  • Step 7: Laravel Upload File Via Api Using PostMan

Checkout Full Article here

#uploading files via laravel api #laravel file upload api using postman #laravel image upload via api #upload image using laravel api #image upload api in laravel validation #laravel send file to api

I am Developer


Crop and Resize Image Before Upload In Laravel Using with jQuery Copper JS

Crop and resize image size before upload in laravel using jquery copper js. In this post, i will show you how to crop and resize image size in laravel using jQuery copper js in laravel.

This laravel crop image before upload using cropper js looks like:

laravel crop image before upload

Laravel Crop Image Before Uploading using Cropper js Tutorial

Laravel crop image before upload tutorial, follow the following steps and learn how to use cropper js to crop image before uploading in laravel app:

  • Step 1: Install New Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration & Model
  • Step 4: Add Route
  • Step 5: Create Controller By Artisan
  • Step 6: Create Blade View
  • Step 7: Make Upload Directory
  • Step 8: Start Development Server


Live Demo Laravel Crop image Before Upload.

#laravel crop image before upload, #laravel crop and resize image using cropper.js #ajax image upload and crop with jquery and laravel #crop and upload image ajax jquery laravel #crop image while uploading with jquery laravel #image crop and upload using jquery with laravel ajax