Page 1 of 2
problems with uploading Files (uppy)
Posted: Fri Dec 02, 2022 2:17 pm
by oli
Hello,
I used the new input type "File" to upload files.
Unfortunately it doesn't work. I can select files but after saving the record the selected file name disappears.
I didn't get any information during the upload or any error in the debug results.
Are there any prerequisites I need to consider?
What I did was:
1. opened the form I'd like to add the uploader
2. added the new object (Type: File)
3. created a database field therefore
4. adjusted size and location on the form
I there anything I missed ?
BR, Oli
Re: problems with uploading Files (uppy)
Posted: Fri Dec 02, 2022 2:45 pm
by kev1n
What does you code look like?
Re: problems with uploading Files (uppy)
Posted: Fri Dec 02, 2022 3:02 pm
by oli
I just used the objects without changing any code (I am using the latest nuBuilder Version).
Re: problems with uploading Files (uppy)
Posted: Fri Dec 02, 2022 3:21 pm
by kev1n
The code doesn't store the file name in a nuBuilder object. To do so, you'll need to place a function nuOnFileUploadComplete() in the form's Custom Code and retrieve the file name there.
(replace your_file_object_id with your field id)
Code: Select all
function nuOnFileUploadComplete(source, id, result) {
// Store file name in a nuBuilder text field (just one file handled)
if (result.successful.length > 0) {
nuSetValue('your_file_object_id', result.successful[0].response.body.file);
} else {
if (result.failed.length > 0) {
result.failed.forEach((file) => {
nuMessage(file.response.body.message)
})
}
}
}
Re: problems with uploading Files (uppy)
Posted: Fri Dec 09, 2022 10:59 am
by kev1n
Is this solved?
Re: problems with uploading Files (uppy)
Posted: Sun Dec 11, 2022 5:12 pm
by oli
Thank you Kev!n,
yes, it' s solved.
Re: problems with uploading Files (uppy)
Posted: Fri Dec 30, 2022 12:53 pm
by yvesf
And what about uploading several images ? It works perfectly for 1 image.
Re: problems with uploading Files (uppy)
Posted: Fri Dec 30, 2022 2:51 pm
by yvesf
The code for taking into account the complete set of images uploaded to be put behind the custom code of your form
Code: Select all
function nuOnFileUploadComplete(source, id, result) {
// Store file name in a nuBuilder text field (just one file handled)
let text="";
if (result.successful.length > 0) {
for (let i = 0, len =result.successful.length; i < len; i++) {
text += result.successful[i].response.body.file + "\n";
}
nuSetValue('your_field_set_as_textarea', nuGetValue('rv_file_lists') + text);
} else {
if (result.failed.length > 0) {
result.failed.forEach((file) => {
nuMessage(file.response.body.message)
})
}
}
}
Re: problems with uploading Files (uppy)
Posted: Fri Dec 30, 2022 3:39 pm
by kev1n
Is this solved?
Re: problems with uploading Files (uppy)
Posted: Fri Dec 30, 2022 5:13 pm
by yvesf
Yes solved, thanks Kev1n.