The very basic is that Android code is written in Java language. As with any programming language , we can use the File source, fetch the file object which in this case is a .txt file, that needs to be uploaded to the server. Before doing any further processing with the source file, make a check if the source file actually exists in the path, if not please skip and terminate.
If the source file does exist, allocate a new object of FileInputStream with the source file. Open a new network URL connection and set the content type, filename etc in the request parameters of this newly created request. Create the new data output stream and perform a file write, which will upload the file into the destination server.