Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
problems with uploading Files (uppy) Topic is solved
problems with uploading Files (uppy)
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
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
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: problems with uploading Files (uppy)
I just used the objects without changing any code (I am using the latest nuBuilder Version).
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: problems with uploading Files (uppy)
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)
(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)
})
}
}
}
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
-
- Posts: 347
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 94 times
- Been thanked: 12 times
Re: problems with uploading Files (uppy)
And what about uploading several images ? It works perfectly for 1 image.
-
- Posts: 347
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 94 times
- Been thanked: 12 times
Re: problems with uploading Files (uppy)
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)
})
}
}
}
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact: