<style>
.box__dragndrop,
.box__uploading,
.box__success,
.box__error {
display: none;
}
</style>
<form class="box" method="post" action="" enctype="multipart/form-data">
<div class="box__input">
<input class="box__file" type="file" name="files[]" id="file" data-multiple-caption="{count} files selected" multiple />
<label for="file"><strong>Choose a file</strong><span class="box__dragndrop"> or drag it here</span>.</label>
<button class="box__button" type="submit">Upload</button>
</div>
<div class="box__uploading">Uploading…</div>
<div class="box__success">Done!</div>
<div class="box__error">Error! <span></span>.</div>
</form>
<script>
var div = document.createElement('div');
return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)
return 'FormData' in window;
'FileReader' in window
var isAdvancedUpload = function() {
var div = document.createElement('div');
return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
}();
if (isAdvancedUpload) {
// ...
}
</script>
<script>
var $form = $('.box');
if (isAdvancedUpload) {
$form.addClass('has-advanced-upload');
}
</script>
<style>
.box.has-advanced-upload {
background-color: white;
outline: 2px dashed black;
outline-offset: -10px;
}
.box.has-advanced-upload .box__dragndrop {
display: inline;
}
</style>