Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

problems with uploading Files (uppy) Topic is solved

Questions related to using nuBuilder Forte.
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

problems with uploading Files (uppy)

Unread post 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
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: problems with uploading Files (uppy)

Unread post by kev1n »

What does you code look like?
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Re: problems with uploading Files (uppy)

Unread post by oli »

I just used the objects without changing any code (I am using the latest nuBuilder Version).
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: problems with uploading Files (uppy)

Unread post 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)
			})
		}

	}

}

kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: problems with uploading Files (uppy)

Unread post by kev1n »

Is this solved?
oli
Posts: 118
Joined: Sat Mar 20, 2021 3:22 pm
Has thanked: 4 times

Re: problems with uploading Files (uppy)

Unread post by oli »

Thank you Kev!n,
yes, it' s solved.
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: problems with uploading Files (uppy)

Unread post by yvesf »

And what about uploading several images ? It works perfectly for 1 image.
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: problems with uploading Files (uppy)

Unread post 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)
			})
		}

	}

}
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: problems with uploading Files (uppy)

Unread post by kev1n »

Is this solved?
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: problems with uploading Files (uppy)

Unread post by yvesf »

Yes solved, thanks Kev1n.
Post Reply