Append fields to file when uploading

HI!

I’d like to suggest an improvement to ‘Uploader’ control…

When uploading a file, I’d like to set some fields of my system…

I know that I can upload a file, return some id and reuse it with my desired fields, but by a design choice, I must do with a single post…

Using crome’s debug, I could inspect ‘send’ method and write an variant, but I can’t do the same with ‘minimized’ version of webix.

The core was something like that:

var item = sender.files.getItem(id);
var formData = new FormData();
formData.append("myField", "myValue"); // <-- this works for me!
formData.append(item.file.name, item.file);

Is it so hard to provide a way to append some info when uploading?

(breaklines at this forum isn’t working well)

Thanks for suggestion.

It will be added to the oncoming Webix 2.1

This version will allow to define the data per file

$$("uploader").send(id, { param1:"value1", param2:"value2"});

or configure this values for autosend mode

$$("uploader").define("formData", { param1:"value1", param2:"value2"});

After a lot of work, I could understand the ‘minified’ version of ‘send’ method…
My sugestion to ‘sendAdvanced’ method is at http://pastebin.com/Wq14ZgnB
A sample of usage as could be: http://pastebin.com/Hpb0aA4V

When you use the cycle for sending a form including images, it is important to be able to include parameter values AND have a callback function. Otherwise when sending the form you will never know when the uploading is finished.

Uploader control has the related event
http://docs.webix.com/api__ui.uploader_onuploadcomplete_event.html

Also, the send method of uploader can have both callback and extra data

uploader.send(function(){
   //after-upload-complete handler
}, {
   key:value
});