How to Get Uploaded File Size in Laravel?

23-Aug-2022

.

Admin

How to Get Uploaded File Size in Laravel?

Hello Friends,

In this tutorial we will go over the demonstration of how to get uploaded file size in laravel. we will help you to give example of laravel get size from uploaded file example. I would like to show you laravel file size get. I would like to show you get file size in laravel. You just need to some steps to done laravel check file size before upload.

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 version.

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