Uploaded file is to large

PHP has a setting in the php.ini named upload_max_filesize. If your uploaded file is larger, you will get an error code in the $_FILES array. But here is another limit. If post_max_size is to small for the uploaded data, you will get emtpy $_FILES and $_POST arrays. So how to output an error message for the user? I found $_SERVER['CONTENT_LENGTH']. It contains the byte length of the content.
if (isset($_SERVER['CONTENT_LENGTH']) &&
     $this->iniGetSize('post_max_size')) {
   $this->_gt('Uploaded data is to large.'));
Does anybody know a better solution or problems with that one?