React dropzone, how to upload image?
React Dropzone returns an array of File objects which can be sent to a server with a multi-part request. Depend on the library you use it can be done differently.
Using Fetch API it looks as follows:
var formData = new FormData();formData.append('file', files[0]);fetch('http://server.com/api/upload', { method: 'POST', body: formData})
Using Superagent you would do something like:
var req = request.post('/api/upload'); req.attach(file.name, files[0]); req.end(callback);