File Drop Zone
Drop files on a large target or click it to use the native file picker.
or click to choose one, up to 5 MB
<div class="mero-scope" data-mero-scope>
<div class="mero-field">
<label class="mero-label" for="demo-drop-zone">Import contacts</label>
<div class="mero-drop-zone" data-mero-drop>
<input class="mero-file" id="demo-drop-zone" name="import" type="file" accept=".csv,.xlsx" aria-describedby="demo-drop-zone-hint">
<p aria-hidden="true"><strong>Drop a CSV or XLSX file</strong></p>
<p id="demo-drop-zone-hint">or click to choose one, up to 5 MB</p>
<span data-mero-file-name aria-live="polite"></span>
</div>
</div>
</div>Put the field in a plain <form method="post" enctype="multipart/form-data">. Without scripts the native file input shows inside the zone with its own file name, and the form submits as usual. With mero.js the input covers the whole zone, and a drop anywhere on a data-mero-drop zone fills its file input, whatever its name, and fires change. The zone gets data-dragging while files are over it, and data-mero-file-name lists the chosen files. Add multiple to accept several files. Your server still checks the type and size.
Use in your app
Copy these tags into your page head once. Serve the files at the paths shown, then add the example’s template to your page.
<link rel="stylesheet" href="/mero.css">
<script defer src="/mero.js"></script>