Is this possible? I have a working sample that uploads single selected attachments, but I would like to upload multiple attachments with one click. The file input HTML control supports multiple attachments, but when I try to pass an input form element with the "multiple" value into the FeatureLayer addAttachment method (FeatureLayer | API Reference | ArcGIS API for JavaScript ), I get this error message:
TypeError: Cannot read property 'attachmentId' of undefined
The failure seems to occur on this line:
attachmentId = result.attachmentId;
Here is some relevant code. apologies if the code looks wonky, the editor seems to be having issues...
//Add Input file components for file upload
var fileInputForm = domConstruct.create("form");
var inputNode = domConstruct.create("input", { id: "files", type: "file", name: "attachment", multiple: "multiple" });
var fileList = domConstruct.create("output", { id: "list" });
domConstruct.place(inputNode, fileInputForm);
domConstruct.place(fileInputForm, addDiv);
gLayer.addAttachment(objIdVal, fileInputForm, function (result) {
console.log(result);
var fileInput = query("input", fileInputForm)[0];
array.forEach(fileInput.files, function (file) {
var fileName = file.name
//This code works for single attachments when the multiple keywork in the input form is removed..
//var fileName = fileInput.value;
//fileName = fileName.substr(fileName.lastIndexOf("\\") + 1);
//Do something with the file names here..
}
}, function (error) {
console.log(error);
errorUploadMessage.innerHTML = "ERROR:" + error.message;
domStyle.set(errorUploadMessage, "display", "block");
});
;