Answer the question
In order to leave comments, you need to log in
How to accept an image on the server?
On the client I do:
let button = document.getElementById('btn')
button.onclick = () => {
var formData = new FormData();
formData.append("zdarov", document.getElementById("file").files[0], 'a.png');
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3000/api");
xhr.send(formData);
}
router.post('/api', ctx => {
ctx.status = 200
console.log(ctx.request.body)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question