Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

Does this script still work? I found it in an old thread?

I'm assuming the data source would be something like:

LoginDB__files_upload_service // a service which uploads files to the files collection

and the file list would be at least 1 file such as:

image_base64_1 // A picture from the camera

or an array of file names taken with the camera?

I have saved 6 pictures from my camera into local storage and would like to upload all 6 to the files database. They are stored in Local Storage:

image_base64_1
image_base64_2
image_base64_3
image_base64_4
image_base64_5
image_base64_6

// Here's the function I'm talking about

function uploadMultipleFilesHelperNew(datasource, fileList) {
var isCorrectService = false;
if (datasource) {
if (datasource.service && datasource.service.requestOptions) {
var options = datasource.service.requestOptions;
isCorrectService = options.type === 'post' && options.contentType === false && /^.*\/files$/i.test(options.url);
}
}
if (isCorrectService) {
if (fileList) {
var data = new FormData();
for (var i = 0; i < fileList.length; i++) {
appendItem(data, fileList);
}
try {
datasource.execute({
'allowDataModification': false,
'processData': false,
'body': {data: data},
'cache': false
});
} catch (exception) {
console.log(exception.name + ' ' + exception.message);
hideSpinner();
}
}
} else {
console.warn('This data source not be supported in the method of upload multiple files');
}
function appendItem(formData, item) {
if (item) {
if (item.type === 'file') {
item = item.files;
}
if (item instanceof FileList) {
for (var i = 0; i < item.length; i++) {
appendItem(formData, item);
}
return;
}
var name;
if (item.name) {
name = item.name;
}
formData.append(name, item);
}
}
}

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Multiple upload files new function

Hello Al,

Please follow this tutorial https://devcenter.appery.io/tutorials...

Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

I'm getting the error: file_input is not defined

Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

Now I'm getting a success but the files are not there.

Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

OK .... finally got it working. Uploads 3 files from my computer which I can select all at one time. I guess what I need to do is call this function for every file I need to upload and pass it the file names. I have stored the images from the camers as:

uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_0'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_1'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_2'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_3'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_4'));
uploadMultipleFilesHelper(uploadService, Apperyio('image_base64_5'));

Is there a way to pass all file names at the same time instead of calling the upload function 1 time for every file?

Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

I am stuck again, this will not upload photos from the camera as I have mentioned above. It will upload photos from my computer but that is not what I am trying to do. I need this to upload photos taken from the camera.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Multiple upload files new function

Hello Al -

In this case please check this tutorial: https://devcenter.appery.io/documenta...

Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

Over and over again lol. I have been to that tutorial and I have tried this both ways. I am trying to upload 6 pictures from the camera. What is the proper way to do this? Is it a combination of both tutorials? I just keep running around in circles going through your documentation.

Can this be done?
Am I wasting my time?
I have been working on this for 2 weeks. If I am missing something can you let me know what it is lol.

Al7638578
Posts: 0
Joined: Mon Jul 13, 2015 8:43 pm

Multiple upload files new function

This isn't solved, who marked it as solved?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Multiple upload files new function

Hello Al,

We used to have this tutorial, please check the app made with it, hope it will be helpful for you. Also please don't forget to link it with your db :
https://www.dropbox.com/s/mwhtf5z3zjh...

Return to “Issues”