Dropzonejs::Rails4
Integrate Matias Meno's Dropzone awesome file upload JS library right into the Asset pipeline of your Rails apps.
Installation and usage
First add dropzonejs-rails4 to your Gemfile and, as you already know, bundle it and then restart your Rails app:
# On your Gemfile
gem 'dropzonejs-rails4'$ bundle installAfter that, you need to make dropzone.js available on your pages. To do that, you can add it to your application.js file, like this:
//= require dropzonejs/dropzoneAnd if you would like to use one of the styles bundled with Dropzone, add to your application.css:
*= require dropzonejs/dropzone/basicor
*= require dropzonejs/dropzone/dropzoneAnd that, add code to view
The typical way of using dropzone is by creating a form element with the class dropzone
<form action="/file-upload" class="dropzone" id="my-awesome-dropzone"></form>
Alternatively you can create dropzones programmaticaly (even on non form elements) by instantiating the Dropzone class
html
<form action="/file-upload" class="dropzone">
<div class="fallback">
<input name="file" type="file" multiple />
</div>
</form>
javascript
// Dropzone class:
var myDropzone = new Dropzone("div#myId", { url: "/file/post"});
or if you use jQuery, you can use the jQuery plugin Dropzone ships with:
// jQuery
$("div#myId").dropzone({ url: "/file/post" });
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request