English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP filesize() Function Usage and Example

PHP Filesystem Reference Manual

The filesize() function can return the size of the specified file. If successful, this function can return the file size (in bytes), if failed, then return false.

Syntax

int filesize ( string $filename )

If an error occurs, this function can return the file size (in bytes) or false (and can generate an E_WARNING level error).

Online Example

<?php
   $filename = "sample.txt";
   echo $filename . ': ' . filesize($filename) . ' bytes';
?>
Test and See‹/›

Output Result

sample.txt: 27 bytes

PHP Filesystem Reference Manual