I've changed the template so that the form is always there, rather than having a link to the upload page. This form is then being used as the basis for the upload, rather than defining it in the JavaScript. Not sure why I didn't do this the first time round.