Determining File Sizes in PHP
The filesize function allows you to find
the size of a file in bytes. Example:
php<?php
echo filesize('test.txt');
?>
The size in bytes can easily be converted to kilobytes:
php<?php
echo filesize('test.txt') / 1024;
?>
And now let's convert it to megabytes:
php<?php
echo filesize('test.txt') / (1024 * 1024);
?>
Задание 1
Let there be a file in the root of your site. Find out its size and display it on the screen.
Задание 2
Modify the previous task so that the file size is displayed in kilobytes.
Задание 3
Place some picture larger than a megabyte in the root of your site. Find out the size of this file and convert it to megabytes.
Задание 4
Place some movie larger than a gigabyte in the root of your site. Find out the size of this file and convert it to gigabytes.