Drop-Zone
Overview
The Style Kit includes classes and a recommended implementation for using Dropzone.js to upload multiple files.
Dependencies
This plugin depends upon:
See distribution for how to include these dependencies.
Server requirements
You will need an endpoint that can accept form submissions with file uploads, specifically the multipart/form-data
encoding type.
In modern browsers this will trigger a CORS preflight request due to the use of a Non-CORS-safelisted request-headers. In addition to the Access-Control-Allow-Origin and Access-Control-Allow-Methods headers, you will need to include these header names in a Access-Control-Allow-Headers header:
Cache-Control
X-Requested-With
Header names are not case sensitive.
Uses
Drop-zones can be useful when multiple files need to be uploaded and allow users to add or remove files multiple times.
Standard file upload fields should be used instead of drop-zones where only a single file is needed as they are part of the HTML standard.
Examples
<form method="POST" enctype="multipart/form-data" action="https://bas-style-kit-file-upload.herokuapp.com/upload-single">
<fieldset class="bsk-form-group">
<label class="bsk-control-label" for="dropzone-1">File upload (Drag and Drop)</label>
<div id="dropzone-1" class="bsk-form-control bsk-dropzone">
<div class="bsk-dropzone-upload-target bsk-target-initial">
<div class="bsk-target-inner">Click to select files or drag them here</div>
</div>
<div class="bsk-alert bsk-alert-block bsk-alert-outline bsk-alert-danger bsk-dropzone-errors-container">
<h4>There is a problem</h4>
<p>One or more files could not be uploaded. If possible, fix the problem and try again.</p>
<br />
<ul></ul>
</div>
<div class="bsk-dropzone-file-list">
<div class="bsk-container-fluid">
<header class="bsk-row bsk-dropzone-file-list-header">
<div class="bsk-col-24-md-15">File Name</div>
<div class="bsk-col-24-md-2">File Size</div>
<div class="bsk-col-24-md-4">File Status</div>
<div class="bsk-col-24-md-3 bsk-header-actions"> Actions</div>
</header>
<div class="bsk-dropzone-file-list-items">
<div class="bsk-row bsk-dropzone-file-list-item">
<div class="bsk-col-24-md-15" data-dz-name></div>
<div class="bsk-col-24-md-2" data-dz-size></div>
<div class="bsk-col-24-md-4" data-bsk-dz-status></div>
<div class="bsk-col-24-md-3 bsk-item-action-remove">
<a class="bsk-text-danger" href="#" data-dz-remove>Remove</a>
</div>
<div class="bsk-item-progress-bar" style="width:0%;" data-dz-uploadprogress></div>
</div>
</div>
<div class="bsk-dropzone-upload-target bsk-target-additional">
<div class="bsk-target-inner">Click to select more files or drag them here</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
The corresponding JavaScript for this example: