more robust file uploading