you don't indicate if you need it for an asp.net or for a php page.
PHP will give better results than javascript but will still be a bit off as it can't really touch the post data streaming in. The RAW_POST_DATA variable is only populated if it doesn't recognize the mime type but you need a valid mime type for file transfers to work. PHP will loose more accuracy on large files than on smaller ones.
Here's an article on an .NET control that will do what you need:
http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti.htmlPerl would be another option which can touch the data stream.