If you’re working on a project for WordPress that’s going to allow users to upload files – be it a video, an image, a CSV, or any other type of data – then you’re likely going to be faced with a situation where you’re going to need to determine if a file is too large for WordPress.

Yeah, it’s a little too large.
What’s considered “too large” can be related to any number of factors:
- The size of the file is larger than you want to accept (or the file system accepts)
- A PHP timeout occurs when uploading a file because of its size
- The file system doesn’t have enough space
- …and so on.
Whatever the case may be, there are two things that you’re going to need to be able to do:
- Determine if the file fits within constraint of the system (whatever the constraint is)
- Display an error message to the user before the upload occurs
It doesn’t exactly provide for a stellar experience when trying to upload something only to have it rejected by the server without a proper error message, does it?



