Home > Article > Backend Development > How to use php to get the size of a file and judge it? (code example)
This article mainly introduces issues related to PHP obtaining file size. Hope it helps friends in need. First, I will introduce you to a PHP function, filesize, which is
php to get the file size. The usage is as follows:
#Output: php file size 1024 bytes. Note: Because PHP’s integer type is a signed integer and many platforms use 32-bit integers, for 2GB For the above files, some file system functions may return unexpected results.
Then the specific code examples for PHP to determine the file size are as follows:
(Here are some simple operations on the database)Note: First find the database mpicture, select the table picture, execute the mysql statement of $p, and assign it to result, obtain the data quantity of result, and obtain the path of the picture. Then use the if statement to determine if it is less than 5K, then execute the code. This article introduces the method of obtaining and judging the size of PHP files. It has certain reference value and I hope it will be helpful to everyone. 【Recommended related articles】
php file size detection and large file upload processing
php method to obtain file size Example code
How does php calculate the folder size (recursively)
How to limit uploaded files by configuring php files size?
The above is the detailed content of How to use php to get the size of a file and judge it? (code example). For more information, please follow other related articles on the PHP Chinese website!