Well as far as I know, PHP will never give error before starting to upload. It will always check when the form will be submitted. (May be there are ways if any I dunno any but, more advance users can help it then.)
If you wanna check that before sending information to server, then you need some client side function or script.
While as for PHP goes, You need to define the file size to be accepted and then check that value with
I’ve found that this just REALLY frustrates users. Most of them don’t realize why their upload was rejected. MANY of them confuse image size (5" X 7") with File Size.
Long story short, I basically opened up the floodgates on my sites and allow virtually any size image to be uploaded. I then use an image processing script to size it down to the dimensions the site needs.
Now, that being said, I have full control over the people doing this uploading. So giving them full access such as this is not a compromise for anything other than server space (which is ultra cheap anyways).
Now, if you are doing this for a social network or something where any Joe Schmoe will be able to upload then yes, you may have to restrict. But otherwise, let them post whatever it is they want to post.