As far as i know there is no way to detect the file size serverside BEFORE the upload
The way to do this if you use a flash uploader such as SWFupload or uploadify
and you can limit the file size and extension from swf upload or uploadify ( i recomend using uploadify )