Fix scoping issues with uploading file