check file size file.size / 1024 / 1024 < 2; code example Example: php get size of file $fileSizeInBytes=filesize("/path/to/myfile.txt");