How to Get File Size from URL in Laravel?
We sometimes require to get file size from path in laravel, so if you need to get file size from url then no worry and you can get using File facade. File facade provide several function that way we can get size of file or image.
you will able to get file size from path in laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 version1
In bellow example i just give you path of my images folder inside public folder and one image, that give path as argument of size function:
Example 1: using Storage
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Storage;
class DemoController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function index()
{
$fileSize = Storage::size('public/settings/file.jpg');;
dd($fileSize);
}
}
Example 2: Using File
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use File;
class DemoController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function index()
{
$fileSize = File::size(public_path('images/1461177230.jpg'));
dd($fileSize);
}
}
I hope it can help you...

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- PHP Laravel Left Join Query Example
- PHP Laravel Inner Join Query Example
- How to Delete File from Public Folder / Storage Folder in Laravel?
- Laravel Move File from One Folder to Another Example
- Laravel Copy File from One Folder to Another Example
- How to display image from storage folder in Laravel?
- MySql comma separated column join in PHP Laravel
- Laravel Create and Download Zip File Example using chumper/zipper
- Laravel - Inner Join with Multiple Conditions Example using Query Builder
- How to Count Files in a Directory using Laravel?
- Laravel Create JSON File & Download From Text Example