Love to help, but this code should be just dandy for just setting a few variables - but it'll never "upload" anything as-is. You'll be needing an HTML/XML form or some other goodies to actually fetch a file from-somewhere to-somewhere.
A) Need some more details as to what you're up to. I have plenty of code snippets you're welcome to look at (or I'll send to ya if ya like) but without knowing the ultimate intended application likely is you'll still be confused.
B) This question probably is probably more apropos in the "Programming" forum.