Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:24:42+00:00 2026-06-06T15:24:42+00:00

I am making a post request on an Arduino device with the Ethernet shield

  • 0

I am making a post request on an Arduino device with the Ethernet shield. The server is a Node.js server, and I have handled the post request server-side with the same results both with formaline and formidable. The POST is processed, but it doesn’t complete the file transfer.

loadstart: {“time”:1339574854222}
“bytesReceived”: 178,
“filesCompleted”: 0

This is the code that sends the post:

String boundary = "--73249889599006000";
String URL = "/upload";
String contentType = "text/plain";
String fileName = "text.txt";

void sendData(){
    String thisFile = "This is not the contents of thisFile";
    Serial.println("connecting...");
    // If you get a connection, report back via serial:
    if (client.connect(server, 80)) {
        Serial.println("connected");

        // Make a HTTP request:
        String postHeader = "POST " + URL + " HTTP/1.1\n";
        postHeader += "Content-Type: multipart/form-data; boundary=";
        postHeader += boundary + "\n";
        postHeader += "Host: 192.168.3.78\n";
        postHeader += "User-Agent: Arduino\n";
        postHeader += "Referer: http://192.168.3.78/upload\n";

        String requestHead = "\n--" + boundary + "\n";
        requestHead += "Content-Disposition: form-data; name=\"upload\"; filename=\"" + fileName + "\"\n";
        requestHead += "Content-Type: " + contentType + "\n\n";

        String tail = "\n--" + boundary + "--\n\n";

        int contentLength = requestHead.length() + thisFile.length() + tail.length();

        postHeader += "Content-Length: " + String(contentLength, DEC) + "\n\n";

        char charBuf0[postHeader.length() + 1];
        postHeader.toCharArray(charBuf0, postHeader.length() + 1);
        client.write(charBuf0);

        char charBuf1[requestHead.length() + 1];
        postHeader.toCharArray(charBuf1, requestHead.length() + 1);
        client.write(charBuf1);

        char charBuf2[thisFile.length() + 1];
        postHeader.toCharArray(charBuf2, thisFile.length() + 1);
        client.write(charBuf2);

        char charBuf3[tail.length() + 1];
        postHeader.toCharArray(charBuf3, tail.length() + 1);
        client.write(charBuf3);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:24:43+00:00Added an answer on June 6, 2026 at 3:24 pm

    Line endings and a few other tweaks sorted it. Here is the updated code that works well with formaline.

    String boundary = "--73249889599006000";
    String URL = "/upload";
    String contentType = "text/plain";
    String fileName = "text.txt";
    
    void sendData(){
      String thisFile = "This is not the contents of thisFile\r\n\r\n";
    
      Serial.println("connecting...");
      // if you get a connection, report back via serial:
      if (client.connect(server, 80)) {
        Serial.println("connected");
    
        // Make a HTTP request:
        String postHeader = "POST " + url + " HTTP/1.1\r\n";
        postHeader += "Content-Type: multipart/form-data; boundary=";
        postHeader += boundary + "\r\n";
        postHeader += "Host: 192.168.3.18\r\n";
        postHeader += "User-Agent: Arduino\r\n";
        postHeader += "Referer: http://192.168.3.18/upload\r\n";
    
        String requestHead = "--" + boundary + "\r\n";
        requestHead += "Content-Disposition: form-data; name=\"upload\"; filename=\"" + fileName + "\"\r\n";
        requestHead += "Content-Type: " + contentType + "\r\n\r\n";
    
        String tail = "--" + boundary + "--\r\n\r\n";
    
        int contentLength = requestHead.length() + thisFile.length() + tail.length();
    
        postHeader += "Content-Length: " + String(contentLength, DEC) + "\n\n";
        Serial.print("Content-Length: ");
        Serial.println(String(contentLength, DEC));
    
        char charBuf0[postHeader.length() + 1];
        postHeader.toCharArray(charBuf0, postHeader.length() + 1);
        client.write(charBuf0);
        Serial.print(charBuf0);
    
        char charBuf1[requestHead.length() + 1];
        requestHead.toCharArray(charBuf1, requestHead.length() + 1);
        client.write(charBuf1);
    
        char charBuf2[thisFile.length() + 1];
        thisFile.toCharArray(charBuf2, thisFile.length() + 1);
        client.write(charBuf2);
        Serial.print(charBuf2);
    
        char charBuf3[tail.length() + 1];
        tail.toCharArray(charBuf3, tail.length() + 1);
        client.write(charBuf3);
        Serial.print(charBuf3);
      } 
      else {
        // kf you didn't get a connection to the server:
        Serial.println("connection failed");
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having troubles debugging a POST request I'm making from my web server to
I'm making a post request to the server and getting back the array of
I have a page that is making an XML POST-Request to an URL on
I'm making a cross-domain POST request and have set up headers in Rails 3.2
I'm making a jQuery Ajax POST request to a PHP script that returns an
I'm making the following request through command-line cURL: curl -X POST http://localhost:8000/api/places/ -vvvv -d
I can't seem to authenticate by making a POST request via ajax! I always
I am making an Ajax post request and I am getting the following as
I'm making an HTTP POST request using curl like this: curl -v -i -d
I'm having trouble making a POST request with a JSON object using Dispatch and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.