# Can't upload file using JS SDK

**URL:** <https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466>\
**Category:** JavaScript\
**Created:** [April 18, 2022, 1:00pm UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466 "2022-04-18T13:00:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![smsm](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/smsm/32/2350_2.png) [@smsm](https://community.sendbird.com/u/smsm)\
**Post date:** [April 18, 2022, 1:00pm UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466/1 "2022-04-18T13:00:32Z")

</div>

We tried everything to use these two methods

1. `sendFileMessage`
2. `updateCurrentUserInfoWithProfileImage`

with converting picture to **file** using this method: [https://stackoverflow.com/a/62432112/4591364](https://stackoverflow.com/a/62432112/4591364)

But we get this error:  
“Invalid Parameters”

So please we need a little support to answer my little question about why the request gets this error “Invalid Parameters”…

---

<div class="post-metadata">

**Author:** ![smsm](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/smsm/32/2350_2.png) [@smsm](https://community.sendbird.com/u/smsm)\
**Post date:** [April 21, 2022, 11:22am UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466/2 "2022-04-21T11:22:03Z")

</div>

Code looks like this:

```auto
fetch(base64String)
  .then((res) => res.blob())
  .then((blob) => {
    const file = new File([blob], fileName, {
      type: "image/png",
    });
    this.sendBird.updateCurrentUserInfoWithProfileImage(user.nickname, file);
  });

```

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)\
**Post date:** [April 22, 2022, 5:01am UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466/3 "2022-04-22T05:01:52Z")

</div>

Hi @smsm,

Welcome to the Sendbird Community.

I put together a quick example of how you might upload images via Javascript: [FileUploadExample (forked) - CodeSandbox](https://codesandbox.io/s/fileuploadexample-forked-36540k?file=/src/App.js)

---

<div class="post-metadata">

**Author:** ![smsm](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/smsm/32/2350_2.png) [@smsm](https://community.sendbird.com/u/smsm)\
**Post date:** [April 23, 2022, 10:28pm UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466/4 "2022-04-23T22:28:50Z")

</div>

Hi @Tyler

We try to upload an image that is not coming from a form…

Still can’t do it till now

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)\
**Post date:** [April 23, 2022, 10:39pm UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466/5 "2022-04-23T22:39:47Z")

</div>

Hello @smsm, Could you tell me where the image is coming from so I can try and reproduce the behavior for you?

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)\
**Post date:** [April 23, 2022, 11:10pm UTC](https://community.sendbird.com/t/cant-upload-file-using-js-sdk/4466/6 "2022-04-23T23:10:15Z")

</div>

@smsm,

I updated the example to use a base64 string: [FileUploadExample (Base64) - CodeSandbox](https://codesandbox.io/s/fileuploadexample-base64-36540k?file=/src/App.js)
