Skip to content

Instantly share code, notes, and snippets.

@stolinski
Created October 18, 2017 14:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stolinski/65079a9ca56a905c6540a9db173e3f8f to your computer and use it in GitHub Desktop.
Save stolinski/65079a9ca56a905c6540a9db173e3f8f to your computer and use it in GitHub Desktop.
Client side Image Upload To Cloudinary React Dropzone
// get's called from react dropzone when file is dropped
onImageDrop = (files) => {
this.handleImageUpload(files[0]);
}
async handleImageUpload(file) {
const data = new FormData();
data.append('file', file);
data.append('upload_preset', CLOUDINARY_UPLOAD_PRESET);
const upload = await fetch(CLOUDINARY_UPLOAD_URL, {
method: 'POST',
body: data,
});
const image = await upload.json();
// then do something with image
}
@fsolar
Copy link

fsolar commented Dec 5, 2017

Hi, how can i use this code to work with multiupload? (im trying with "react-dropzone")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment