Share code for getting correct upload form
Simplify setting of variables