JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/dropzone/3.8.4/dropzone.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/dropzone/3.8.4/css/dropzone.css">
<div ng-app="dropzone" ng-controller="dropZoneCtrl">
<form action="/upload"
class="dropzone"
drop-zone
id="file-dropzone">
</form>
</div>
CSS
.dropzone,
.dropzone * {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.dropzone {
position: relative;
min-height: 260px;
border: 2px dashed rgba(0,0,0,0.3);
-webkit-border-radius: 4px;
border-radius: 4px;
background: rgba(0,0,0,0.03);
padding: 23px;
}
.dropzone.drag-hover {
border-color: rgba(0,0,0,0.15);
background: rgba(0,0,0,0.04);
}
.dropzone.drag-hover .message {
opacity: 0.15;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=15);
filter: alpha(opacity=15);
}
.dropzone.started .message {
opacity: 0;
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
filter: alpha(opacity=0);
}
.dropzone .message {
opacity: 1;
-ms-filter: none;
filter: none;
-webkit-transition: opacity 0.3s ease-in-out;
-moz-transition: opacity 0.3s ease-in-out;
-o-transition: opacity 0.3s ease-in-out;
-ms-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
background: url("http://dl.dropbox.com/u/1559658/dropzone/spritemap.png") no-repeat 0 -108px;
position: absolute;
width: 168px;
height: 157px;
margin-left: -84px;
margin-top: -78.5px;
top: 50%;
left: 50%;
}
.dropzone .message span {
display: none;
}
.dropzone.browser-not-supported {
padding: 30px;
}
.dropzone.browser-not-supported .message {
position: relative;
background: url("http://dl.dropbox.com/u/1559658/dropzone/spritemap.png") no-repeat 0 0;
width: 204px;
height: 108px;
top: 0;
left: 0;
margin-left: 0;
margin-top: 0;
margin-bottom: 20px;
}
.dropzone .preview {
width: 100px;
height: 136px;
display: inline-block;
margin: 18px;
position: relative;
}
.dropzone .preview .details {
width: 100px;
height: 100px;
position: relative;
}
.dropzone .preview .details img {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
}
.dropzone .preview .details .size {
color: #666;
font: 500 31px/31px "League Gothic", sans-serif;
...
JavaScript
/**
* An AngularJS directive for Dropzone.js, http://www.dropzonejs.com/
*
* Usage:
*
* <div ng-app="app" ng-controller="SomeCtrl">
* <button dropzone="dropzoneConfig">
* Drag and drop files here or click to upload
* </button>
* </div>
*/
angular.module('dropzone', []).directive('dropzone', function () {
return function (scope, element, attrs) {
var config, dropzone;
config = {
'options': { // passed into the Dropzone constructor
'url': '/upload'
},
'eventHandlers': {
'sending': function (file, xhr, formData) {
},
'success': function (file, response) {
}
}
};
// create a Dropzone for the element with the given options
dropzone = new Dropzone(element[0], config.options);
// bind the given event handlers
_.each(config.eventHandlers, function (handler, event) {
dropzone.on(event, handler);
});
};
});
angular.module('app', ['dropzone']);
angular.module('app').controller('dropZoneCtrl', function ($scope) {
$scope.dropzoneConfig = {
'options': { // passed into the Dropzone constructor
'url': 'upload.php'
},
'eventHandlers': {
'sending': function (file,formData,xhr) {
},
'success': function (file, response) {
}
}
};
});