How to attach and download files

How to attach and download files

jyd0228jyd0228 Posts: 30Questions: 11Answers: 0
edited March 2021 in TableTools

Hello,
I want to implement a function to attach and download files.
https://editor.datatables.net/examples/advanced/upload-many.html <- I found a way to attach multiple files from that link.(There is more than one file to be attached.)
I want to know how to download the attached file by clicking Download in the table.

Could you please let me know if there is a sample to download the attached files?

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • jyd0228jyd0228 Posts: 30Questions: 11Answers: 0
    edited March 2021

    'dbClean' function does not work when 'upload-many' is used.
    When I deleted uploaded file, it is deleted from the 'USERS_FILES' table,
    but not from the 'FILES' table.
    Can't I use 'dbClean' function in 'upload-many'?

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    It should do, can you give me a link to a page showing the issue and also the PHP code you are using please?

    Thanks,
    Allan

  • jyd0228jyd0228 Posts: 30Questions: 11Answers: 0

    https://editor.datatables.net/examples/advanced/upload-many

    Add 'dbClean' here.

    .dbClean(async function(data) {
    for (let i = 0, ien = data.length; i < ien; i++) {
    await unlink(data[i].system_path);
    }
    return true;
    })

    If you delete the file after adding 'dbClean' and executing it, the file is deleted from the 'users_files' table, but not from the 'files' table.

This discussion has been closed.