The first step is to debug the code.But, there is some problem and it's not working.
Step through doUbload() and look which code is not behaving as it should.
Your code makes almost no tests for many of the calls you make, so any of those could be failing.
Once you know which line of code is the problem, we can look more in to it.
Bookmarks