It is possible to upload multiple files in onedrive(skydrive) using WL.upload ? I tried something but I always get an error like "element must be an html input element" or something like this. I use onedrive sdk 5.6 and the application is build in ASP.NET MVC 5. The problem is that I created an input of type="file" with the attribute multiple set so I can select multiple files from my computer but the upload method from WL api ask for an element property that is actual an id to an input element of type="file". Because my input is set on multiple I tried to iterate through the files that contains and to create an input element to pass to the method, but it's doesn't work because due to security reasons I can set a value of an input element.
So, does anybody knows how I can do this ? Thanks
This is what I have tried:
<div id="save-to-skydrive-dialog-content-multiple">
<p>select a file</p>
<form enctype='multipart/form-data' method='POST'>
<input id="save-to-skydrive-file-input-multiple" type="file" name="files[]" multiple />
</form>
<p>upload file</p>
<button id="save-to-skydrive-upload-multiple-button">upload multiple</button>
</div>
function saveMultipleToSkyDrive() {
WL.fileDialog({
mode: 'save'
}).then(function (response) {
var folder = response.data.folders[0];
var elements = document.getElementById("save-to-skydrive-file-input-multiple").files;
for (var i = 0; i < elements.length; i++) {
var htmlInPutElement = document.createElement('input');
htmlInPutElement.setAttribute('type', 'file');
htmlInPutElement.value = elements.item(i);
WL.api({
})
WL.upload({
path: folder.id,
element: htmlInPutElement,
overwrite: 'rename'
}).then(function (response) {
log("You save to" + response.source + ". " + "Below is the result of the upload");
log("");
log(JSON.stringify(response));
},
function (errorResponse) {
log("WL.upload errorResponse = " + JSON.stringify(errorResponse));
},
function (progress) {
});
}
}, function (errorResponse) {
log("WL.upload errorResponse = " + JSON.stringify(errorResponse));
}
);
Thanks.