Answer the question
In order to leave comments, you need to log in
How to implement sending files through React to the backend?
Good afternoon. The problem is that I have two components: the first is an image drag and drop, all validated files are added to the state, the second is a regular form for creating a post. As I understand it, you can’t embed images in json, but I found a way to send data through FormData, however, I can’t figure out how to send both images (formdata) and the post data itself at the same time. I apologize for being too stupid, if suddenly the answer turns out to be too simple.
Answer the question
In order to leave comments, you need to log in
You send it through the format, new FormData, while the backender must know what the format is. And you will add all other parameters through formdata.append(name, param). Then there will be a full download of the file in the blob view.
Or in the base64 representation, but it will come out more expensive for itself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question