Sending file to remote server using ESP-32

I want to upload the data (stored in FS(file system) of my ESP-32) to the remote server.

and I can’t use web-socket method of remote server.

I’m want to use my ESP as a client to that web page. (is it right???)

I used this code for my HTTP server side:
PHP code:-

<?PHP
  if(!empty($_FILES['uploaded_file']))
  {
    $path = "uploads/";
    $path = $path . basename( $_FILES['uploaded_file']['name']);
​
    if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
      echo "The file ".  basename( $_FILES['uploaded_file']['name']). 
      " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
  }
?>

html code:-

<!DOCTYPE html>
<html>
<head>
  <title>Upload your files</title>
</head>
<body>
  <form enctype="multipart/form-data" action="upload.php" method="POST">
    <p>Upload your file</p>
    <input type="file" name="uploaded_file"></input><br />
    <input type="submit" value="Upload"></input>
  </form>
</body>
</html>

and the web page is working all good… for manual uploading of file.

This code of http-client is just hitting the web-page but not doing anything else.
I refereed this uploading code… but I didn’t get any output.

suggest me any library or any functions for this.

You have to POST your data as multipart.
The first link you posted is a GET example, you need a POST example or find your way through the client API, here: https://cesanta.com/docs/http/api-client.html, and I guess you will have to probably build the multipart yourself.

PS: The second link explains how to handle uploads in Mongoose as a server, not a client.

Thank you for your response @scaprile :smiley:
I’m totally new in the HTTP things… Please suggest me any examples or links for the reference…
I don’t have any problem to use ESP as HTTP server or the client. My main goal is to send a file using ESP to remote server.

POST is a method (verb) for HTTP, is a way to access data in an HTTP server.
multipart/form-data is a MIME extension, currently defined in the RFC-7578, describing how you will format the data you will send to the server.
Basically, the HTML page is GET, that instructs the browser to build a form, the user fills the form, clicks submit, and the browser (client) POSTs the form content to the server.
Google is your friend. Just search for those terms

Thank you @scaprile
please check my code here.
I’m working on this code.