if you are uploading, then you are using server sided code, becaue i dont think you can use ajax to upload a file.
so in what ever server language you're using, get the file via $_POST or whatever and check the file size there... you can also set a maximum file size on forms too.