1

I try to upload photo from my PC using fetch, but code below doesn't work. Url is right. What is the problem?

 static async sendPostFormDataRequest(url) {
    let formData = new FormData();
    formData.append("nameField", "C://sample.jpeg");
    fetch(url, {
        method: "POST",           
        body: formData
    })
}
VLAZ
  • 26,331
  • 9
  • 49
  • 67
Noob
  • 31
  • 3
  • You need to use a `file` input. JavaScript in browser has no direct access to file system. – Ram May 28 '22 at 15:01
  • I'm an absolute beginner in javascript. Could you clarify what it is about with work example? – Noob May 28 '22 at 15:16
  • Please check https://stackoverflow.com/questions/36067767/how-do-i-upload-a-file-with-the-js-fetch-api If the point is automation you should probably use another tool like nodejs – Ram May 28 '22 at 15:46

0 Answers0