Demo only. Everything you upload is visible to every other visitor of this demo, and is deleted again within minutes. Actions are logged, including your IP address. Do not upload anything private, unlawful, or that you are not entitled to share.
Selected file(s):
In window mode the manager gets a popup of its own instead of an iframe, and
onSelectFile is how the picked files come back:
<button type="button" id="buttonOpen">Open Dosiero in new window</button>
<script type="module">
import {Dosiero} from '/dosiero/dosiero.min.mjs';
document.addEventListener('DOMContentLoaded', () => {
const dosiero = new Dosiero({
mode: 'window',
endpoint: window.location.origin + '/endpoint/index.php',
windowWidth: 800,
windowHeight: 600,
onSelectFile: function (files) {
files.forEach(file => {
console.log(file.name, file.size, file.url, file.type);
});
},
});
document.getElementById('buttonOpen').addEventListener('click', () => dosiero.open());
});
</script>
Note where new Dosiero() sits. The instance is built when the page
loads and the click handler does nothing but call open(). That is the reason
construction and opening are two steps: a browser permits window.open() only while
it is still handling a user gesture, and an await — a dynamic
import(), for instance — spends that permission. Load the module up front, open on
the click.
Each file handed to onSelectFile carries name, url,
size and type; type is file or
dir, since a selection can contain folders. The instance stays usable after the
window is closed — pressing the button again reopens it.