How to check filesize using PHP.

Welcome back to shortlearner.com . Today we will see how to check the size of specified file.
PHP provide us an inbuilt function that is filesize() function.

how to check file size in php
the filesize()

Advertisement
function returns the size of the file in bytes on success or
false on failure.

Syntax

Example

filesize() function returns size of the file in bytes default.
for Converting bytes into kilobytes(KB) works by dividing the value by 1024.
PHP is very accurate and it will give us 12 decimal digits ,To avoid this we can make use of the

round() function and specify how many digits of accuracy we’d like to display in our output.

To display the value in megabytes we’ll simply divide by 1024 twice:

Tags: No tags

Comments are closed.