Jibin TJ
Jibin TJ

Reputation: 446

Hitting a nodejs server from a html

Scenario : My html page takes a json file as input and sends it to a nodejs-driven server component. Lets say, myPage.html is a standalone file in this environment.

Requirement: I want to capture the htmlpage request with the json embedded in the httprequest body. I dont know how to call the nodejs application from html page.

Thanks in advance

Upvotes: 1

Views: 76

Answers (1)

Quentin
Quentin

Reputation: 943571

To send a file (embedded in a multipart request body), you just need a regular HTML form.

<form action="http://example.com/nodejs/endpoint" 
      method="post" 
      enctype="multipart/form-data">
    <label>
        Select JSON file
        <input type="file" name="json">
    </label>
    <input type="submit">
</form>

Upvotes: 1

Related Questions