Hi,
I’m using webix form to upload file. I want to get id of the document from response and then add to other part of form to submit it.
This is my upload field in form:
{
rows:[
{
view:"uploader",
id: "documentfilename",
value:"Upload file",
link:"mylist",
name: "files",
multiple:true,
upload:"app_dev.php/api/secure/cases/test-upload",
autosend: false
},
{
view:"list",
id:"mylist", autoheight:true,
template:"<div class='mark'>#name#</div>"
}
]
},
And this is my submit form event:
submitcorrespondence.attachEvent('onItemClick', function()
{
var form = this.getFormView();
if (form.validate()) {
var CorrespondenceData = { direction_of_correpondence: root.$$("direction").getValue(), name: root.$$("namecorrespondence").getValue(), address: root.$$("addresscorrespondence").getValue(), date_and_time: root.$$("datetimecorrespondence").getValue(), subject_matter: root.$$("subjectmatter").getValue(), annexes_nr: root.$$("annexexpc").getValue(),annexes_type: root.$$("annexextypes").getValue(), date_sent: root.$$("datesent").getValue(), date_of_expiration: root.$$("dateexp").getValue(),documents: [root.$$("documentfilename").getValue()],decision_by: root.$$("decison").getValue() ? true : false};
CorrespondenceAdd.addCorrespondence(CorrespondenceData, caseId).then(function (data) {
if(data.id) $state.go("dataentry");
FlashService.alert("Success", "success", "Correspondence has been created.");
});
}
If you can see I’m trying to get value of uploaded file (i will have more than one file) but it is returning empty array.
I also tried to send to send file (like below) and then with console.log to get response, but uploader.send is executing (is calling app_dev.php/api/secure/cases/test-upload") but console.log is not executing.
uploader.send(function(response){
console.log(reponse);
});
Can you please help me get id of files from this response
({"id":109,"documentextension":".pdf","documentfilename":"ccna1.PDF","documentlocalname":"initial","sysdate":"2015-08-03T16:57:58+0200"})
and attaching to other part of the form for submitting it.
Thank you very much.