Answer the question
In order to leave comments, you need to log in
How to send an image to the server emulating FormData?
The problem is the following - I need to send a picture via
I wanted to send it in base64 format via FileReader(), but the server accepts it in binary format (maybe?). How can I emulate data in the same format that FormData creates?<input type="file">
// так отправляется запрос с через FormData.
data.append('windows_view', form.windows_view.value);
data.append('preview_image', form.preview_image.files[0]);
console.log('data: ', data);
axios.post('/panel/apartment/create', data, {
headers: {
'Accept': 'application/json',
'Accept-Language': 'en-US,en;q=0.8',
'Content-Type': `multipart/form-data`,
}
})
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