Laravel 10 Multiple File Upload Tutorial Example

By Hardik Savani November 6, 2023 Category : Laravel

In this example, I will show you laravel 10 multiple file upload example. In this article, we will implement a laravel 10 multiple files upload. We will look at examples of multiple file upload laravel 10. it's a simple example of laravel 10 multiple file upload with preview. follow the below step for uploading multiple files in laravel 10.

Here, we will install laravel 10 and create a simple form with a file input field that you can use to select multiple files. after submitting the form we will store those files in a folder and database.

Step for Laravel 10 Multiple File Upload Example

  • Step 1: Install Laravel 10
  • Step 2: Create Migration and Model
  • Step 3: Create Controller
  • Step 4: Create and Add Routes
  • Step 5: Create Blade File
  • Run Laravel App

So, let's follow the below step to create multiple files upload in the laravel 10 application example.

Step 1: Install Laravel 10

This step is not required; however, if you have not created the laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

Step 2: Create Migration and Model

Here, we will create migration for "files" table, let's run bellow command and update code.

php artisan make:migration create_files_table



use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

return new class extends Migration



* Run the migrations.


* @return void


public function up()


Schema::create('files', function (Blueprint $table) {







* Reverse the migrations.


* @return void


public function down()





Next, run create new migration using laravel migration command as bellow:

php artisan migrate

Now we will create File model by using following command:

php artisan make:model File



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

use Illuminate\Database\Eloquent\Model;

class File extends Model


use HasFactory;

protected $fillable = [




Step 3: Create Controller

In this step, we will create a new FileController; in this file, we will add two method index() and store() for render view and store files into folder and database logic.

Let's create FileController by following command:

php artisan make:controller FileController

next, let's update the following code to Controller File.



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\File;

use Illuminate\View\View;

use Illuminate\Http\RedirectResponse;

class FileController extends Controller



* Display a listing of the resource.


* @return \Illuminate\Http\Response


public function index(): View


return view('fileUpload');



* Display a listing of the resource.


* @return \Illuminate\Http\Response


public function store(Request $request): RedirectResponse



'files' => 'required',

'files.*' => 'required|mimes:pdf,xlx,csv|max:2048',


$files = [];

if ($request->file('files')){

foreach($request->file('files') as $key => $file)


$fileName = time().rand(1,99).'.'.$file->extension();

$file->move(public_path('uploads'), $fileName);

$files[]['name'] = $fileName;



foreach ($files as $key => $file) {



return back()

->with('success','You have successfully upload file.');



Store Files in Storage Folder

$file->storeAs('files', $fileName);

// storage/app/files/file.png

Store Files in Public Folder

$file->move(public_path('files'), $fileName);

// public/files/file.png

Store Files in S3

$file->storeAs('files', $fileName, 's3');

Step 4: Create and Add Routes

Furthermore, open routes/web.php file and add the routes to manage GET and POST requests for render view and store files logic.



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('file-upload', 'index');

Route::post('file-upload', 'store')->name('');


Step 5: Create Blade File

At last step we need to create fileUpload.blade.php file and in this file we will create form with file input button. So copy bellow and put on that file.


<!DOCTYPE html>



<title>Laravel 10 Multiple File Upload Example -</title>

<link href="" rel="stylesheet">



<div class="container">

<div class="panel panel-primary">

<div class="panel-heading">

<h2>Laravel 10 Multiple File Upload Example -</h2>


<div class="panel-body">

@if ($message = Session::get('success'))

<div class="alert alert-success alert-block">

<strong>{{ $message }}</strong>



<form action="{{ route('') }}" method="POST" enctype="multipart/form-data">


<div class="mb-3">

<label class="form-label" for="inputFile">Select Files:</label>






class="form-control @error('files') is-invalid @enderror">


<span class="text-danger">{{ $message }}</span>



<div class="mb-3">

<button type="submit" class="btn btn-success">Upload</button>








Run Laravel App:

All the required steps have been done, now you have to type the given below command and hit enter to run the Laravel app:

php artisan serve

Now, Go to your web browser, type the given URL and view the app output:



I hope it can help you...