FTR, I don't like that this may break when you pass in parameters in the wrong order (files first). Maybe move the upload out of the for-loop?
But it's been like that forever IIUC, so we can leave it like this.