My solution sounds silly but it works :)
Assume that the upload document is named XWiki.Upload. In this document, I change the value of the hidden field "xredirect" to XWiki.DoSomething. I create another document named XWiki.DoSomething, in it, write some code to deal with the file content, blah ... , finally, redirect back to XWiki.Upload.