FILEUP



LOG | FILES | OVERVIEW


F diff --git a/loggedin.js b/loggedin.js --- a/loggedin.js +++ b/loggedin.js
the_file.onchange = on_file_added;
- const files = [];
+ var files = [];
+
+ const pwd = "/";
const pending_uploads = [];
}
- function add_file_visuals(name, pending) {
+ function load_dir(pwd) {
+ var data = new FormData();
+ data.append('path', '/');
+
+ var xhr = new XMLHttpRequest();
+ xhr.open('POST', '/php/readdir.php', true);
+ xhr.onload = function () {
+ for (const f of files)
+ f[1].remove();
+ files = [];
+
+ var json = JSON.parse(this.responseText);
+ for (const f of json) {
+ add_file_visuals(f.name, f.mimetype);
+ }
+ };
+ xhr.send(data);
+ }
+
+ function add_file_visuals(name, mimetype) {
var fileDiv = document.createElement('div');
var img = document.createElement('img');
function begin_upload() {
the_file.click();
}
+
+ load_dir("/");
F diff --git a/php/readdir.php b/php/readdir.php --- a/php/readdir.php +++ b/php/readdir.php
+ <?php
+ echo '[ { "name": "file1.txt", "mimetype": "text/plain", "is_directory": false }, { "name": "file2.pdf", "mimetype": "application/pdf", "is_directory": false }, { "name": "dir", "mimetype": "", "is_directory": true } ] ';
+ ?>