Uploader with config record before upload

Hi, from this SNIPPET!

  1. How can I actually remove file out of the uploader, after remove record in datatable, the files are still there and after adding another, all file will present themselves again.

  2. I’m using go as backend and not used to c.FormFile() that much. I can access file from uploader with 1 file at a time. But can I send them in datatable format (as array) and let backend loop itself? There is also editable field that have to put into database with file location.

Hello @savirusing,

  1. You use a $$("uploadAPI").files.remove(id);
    Please, check out the snippet with example: Code Snippet
    More info about manipulating files you can find in docs.

  2. Please, can you specify your request with more details. Thanks in advance :slight_smile:

I’ve tried to send all datatable with file (serialize the table) and send all to backed using golang.
I will have to move files to some directory but dont know how to send all array of Files at once from webix.
For single file I’m using fiber - c.FormFile("uploader")
but now since it’s in array I will have to use c.MultipartForm()
adding this

onBeforeAjax: function (mode, url, data, request, headers, files) {
                    headers["Content-Type"] = "multipart/form-data";
                }

but still not working. Do you have any sample of this?
my final goal is to move files to specific directory - rename - return new name to the record - add the data to database (I can do it one by one from c.FromFile by upload to temporary folder first but this is not what it supposed to.

or Can we upload using datatable instead?

webix.ajax().headers({ 'Content-Type': 'multipart/form-data' }).post(api, table_row_record, function (text) {
     console.log(text);
});

Im getting this message from go error;

Error: request has no multipart/form-data Content-Type

You can modify your last example a little bit. Use a cycle for:

const files = $$("upload_table").serialize();
const formData = new FormData();

for (let i = 0; i < files.length; i++)
    formData.append(files[i].name, files[i].file)

and upload data by ajax:

webix.ajax()
     .headers({ 'Content-Type': 'multipart/form-data' })
     .post("//docs.webix.com/samples/server/films", formData);

Please, check out the snippet: Code Snippet