-      myfiles.forEach(file => {
-        filesize  += file.size;
-        if (filesize > maxsize) {
-          $("#upload_result").html(kivi.t8("filesize too big: ") + filesize+ kivi.t8(" bytes, max=") + maxsize );
-          return;
-        }
-
-        let data = new FormData();
-        data.append(file);
-        data.append("action", "File/ajax_files_uploaded");
-        data.append("json", "1");
-        data.append("object_type", type);
-        data.append("object_id", id);
-        data.append("file_type", filetype);
-
-        $("#upload_result").html(kivi.t8("start upload"));
-
-        $.ajax({
-          url: "controller.pl",
-          data: data,
-          success: ns.attSuccess,
-          progress: ns.attProgress,
-          error: ns.attFailes,
-          abort: ns.attCanceled
-        });
-      });
+      myfiles.forEach(file => filesize  += file.size);
+
+      if (filesize > maxsize) {
+        M.flash(kivi.t8("filesize too big: ") + ns.format_si(filesize) + " > " + ns.format_si(maxsize));
+        $("#upload_modal").modal("close");
+        return;
+      }
+
+      let data = new FormData();
+      myfiles.forEach(file => data.append("uploadfiles[]", file));
+      data.append("action", "File/ajax_files_uploaded");
+      data.append("json", "1");
+      data.append("object_type", type);
+      data.append("object_id", id);
+      data.append("file_type", "attachment");
+
+      $("#upload_result").html(kivi.t8("start upload"));
+
+      let xhr = new XMLHttpRequest;
+      xhr.open('POST', 'controller.pl', true);
+      xhr.onload = ns.upload_complete;
+      xhr.upload.onprogress = ns.progress;
+      xhr.upload.onerror = ns.failed;
+      xhr.upload.onabort = ns.abort;
+      xhr.send(data);
+
+      ns.upload_in_progress = xhr;