Getting File Sizes PHP Beyond Basics

Getting File Sizes PHP Beyond Basics

PHP, TUTORIALS

Getting File Sizes PHP Beyond Basics




In this lesson Getting File Sizes PHP Beyond Basics we are gonna learn how to calculate the the size of the given file. And also we are going to convert form bytes to kilobytes and from kilobytes to megabytes. Lets jump into the real time example, for getting better understanding,
In this lesson we are using the little bit of OOPS concepts like create a function and call the function and so on.

Getting File Sizes PHP Beyond Basics
In the above example we get the file size defined in the path and it shows the result in the bytes. But we know mostly only in the kilobytes, Mega Bytes and Gigabytes. So we have to convert them into human readable format like KB, MB and GB.




The following example will explains how to convert and show the file size in KB’s and MB’s.

Getting File Sizes PHP Beyond Basics
in the Getting File Sizes PHP Beyond Basics the above shown is the example for how to convert the bytes to Mega Bytes as it is shown in the output.

Getting File Sizes PHP Beyond Basics
The above code is used to convert the bytes to Kilobytes. Here we just change the file name which is file size is less than 1048576.
And these are the variety of functions which are all about how to get the file size and conversion from bytes to KILO and MEGA Bytes.




Download the source code for Getting File Sizes PHP Beyond Basics Viewing Directories.

Leave a Reply