Added function to upload a file (including helper functions).