Use [man]filesize[/man] - PHP doesn't know what size the file is until it's been uploaded, but just because it's been uploaded doesn't mean you have to keep it: if it's too big, output your error message. If you don't do anything to keep it it will be deleted when the script finishes. You can specify a MAXFILESIZE attribute in the form, but the browser is not beholden to obey it.