Move file uploading to a utility function
Encode files within a temporary local directory