How do I upload a text file to a web server(http), then read the output?

How do I upload a text file to a web server(http), then read the output?

FileChooser fileChooser("Select file to upload",
File::getSpecialLocation(File::userHomeDirectory), "*.txt");
    
if(fileChooser.browseForFileToOpen()){
        
    File fileToUpload(fileChooser.getResult());
        
    URL url = URL("http://example.com/upload_file.php");
        
     // upload text file
     // read url output
}

Maybe add the file to the URL using URL::withFileToUpload() and then call URL::readEntireBinaryStream()? Haven’t tried, but something along these lines:

File fileToUpload(fileChooser.getResult());    
URL url = URL("http://example.com/upload_file.php").withFileToUpload (fileToUpload);
MemoryBlock block;
if (url.readEntireBinaryStream (block, true)) {
    
}

You may also consider to use URL::downloadToFile(), which runs asynchronously…

Thanks. I am now making progress.