Hack: Async Upload

bugs:
Compatible with: R6.0
Current version: 0.1.beta
Credits: WikiAdmin

{{upload}}


async_upload_patch.tar.gz


Put the files in the following folders:

folder / file
action/upload.php
action/template/upload.tpl
js/upload.js
handler/page/upload.php
handler/page/template/upload.tpl

1. Documentation

Action – module for bulk upload files on a WackoWiki site with a record in the database.


Features:

  1. uses Fetch API to upload (even large) files
  2. chose and upload multiple files at once

const url = 'handler/page/upload.php';
const form = document.querySelector('form');
 
form.addEventListener('submit', e => {
    e.preventDefault();
 
    const files = document.querySelector('[type=file]').files;
    const formData = new FormData();
 
    for (let i = 0; i < files.length; i++)
    {
        let file = files[i];
 
        formData.append('files[]', file);
    }
 
    fetch(url, {
        method: 'POST',
        body: formData
    }).then(response => {
        console.log(response);
    });
});

Resources

1.1. Configuration

  • none so far 
  • read the TODO comments in the files

1.2. How to use it

– same as current upload action


Drop-in replacement, just copy the files of this patch over the current onces.


2. Changelog

0.1 Intitial version – proof of concept

3. To Do

  1. may crash the browser while uploading a stack of large files
    1. set file limit
  2. provide a common summary after the upload of multiple files
    1. currently it shows only the last result
  3. preview files for upload
    1. shows thumbnail of image
    2. modify the file name and the file description
  4. test features

Show Files (1 file)