Laravel Get File Size Uploaded Code Example

Aug 23, 2022 . Admin

Hello Friends,

This tutorial shows you Laravel Get File Size Uploaded Code Example. it's simple example of get file size in laravel. This post will give you simple example of laravel get the size from an uploaded file example. This article goes in detail on how to get uploaded file size in laravel. Here, Create a basic example of laravel file size get.

Many times we need file size in Laravel to check uploaded files or something else. But many of us don't know how to get file size in Laravel. So I am here to discuss the way of getting file size in the Laravel application. I will show you how to get file size from the getSize() function.

You can use this example with laravel 6, laravel 7, laravel 8 and laravel 9 versions.

So let's start with following examples:

Download Laravel

Let us begin the tutorial by installing a new laravel application. if you have already created the project, then skip the following step.

composer create-project laravel/laravel example-app
Get Uploaded File Size
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PostController extends Controller
{

    /**
     * Write Your Code..
     *
     * @return string
    */
    public function store(Request $request)
    {
        dd($request->file->getSize());
    }
}

Output:
1423029

now it works...

I hope it can help you...

#Laravel