Home  >  Article  >  Backend Development  >  How to use php to get the size of a file and judge it? (code example)

How to use php to get the size of a file and judge it? (code example)

藏色散人
藏色散人Original
2018-08-13 11:23:407371browse

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:

How to use php to get the size of a file and judge it? (code example)

#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.

How to use php to get the size of a file and judge it? (code example)

Then the specific code examples for PHP to determine the file size are as follows:

(Here are some simple operations on the database)

How to use php to get the size of a file and judge it? (code example)

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn