# How to upload a file using http request

**URL:** <https://discourse.nodered.org/t/how-to-upload-a-file-using-http-request/87737>\
**Category:** General\
**Tags:** http-request\
**Created:** [6 May 2024 06:38 UTC](https://discourse.nodered.org/t/how-to-upload-a-file-using-http-request/87737 "2024-05-06T06:38:22Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![praveenkumarreddy849](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@praveenkumarreddy849](https://discourse.nodered.org/u/praveenkumarreddy849)\
**Post date:** [7 May 2024 10:28 UTC](https://discourse.nodered.org/t/how-to-upload-a-file-using-http-request/87737/3 "2024-05-07T10:28:15Z")

</div>

Hi @Steve-Mcl ,

Thanks for your Suggestion,

I have found a[thread for file upload scenario](https://discourse.nodered.org/t/form-data-multipart-encoded-request-with-pdf-file-attached-into-the-body/44749)

Which has given me a path to resolve this as below

```auto
var base64Data = msg.encodedFile;
var buffer = Buffer.from(base64Data, 'base64');

var formData = {
    file: {
        value: buffer,
        options: {
            filename: `${msg.fileName}`,
            contentType:`${msg.fileType}`
        }
    },
}

```

---

_[View the full topic](https://discourse.nodered.org/t/how-to-upload-a-file-using-http-request/87737)._
