Skip to content

Instantly share code, notes, and snippets.

@basicallydan
Last active January 25, 2021 02:25
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save basicallydan/11c8c02bdaa1ced2e842 to your computer and use it in GitHub Desktop.
Upload from the browser to Cloudinary with no server
<!-- This example is for a blog post that can be found at http://danhough.com/blog/dropzone-cloudinary/ - read there to find out how to use it -->
<!DOCTYPE html>
<html>
<head>
<title>Dropzone Example</title>
</head>
<body>
<div id="dropzone-area" style="width:700px;height:700px;display:block;margin:20px auto;border:1px solid red;"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/dropzone.js"></script>
<script type="text/javascript">
var myDropzone = new Dropzone(document.getElementById('dropzone-area'), {
uploadMultiple: false,
acceptedFiles:'.jpg,.png,.jpeg,.gif',
parallelUploads: 6,
url: 'https://api.cloudinary.com/v1_1/cloud9/image/upload'
});
myDropzone.on('sending', function (file, xhr, formData) {
formData.append('api_key', 123456789123456);
formData.append('timestamp', Date.now() / 1000 | 0);
formData.append('upload_preset', 'presetname');
});
</script>
</body>
</html>
@bobmoff
Copy link

bobmoff commented Mar 15, 2017

awesome! exactly what i needed. thx

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