A button that allow user to upload different type of files

Hi everyone~
Wix is very amazing for me and i nearly finish my first website with it.
There is one problem that i need help:
I want to create a button that allow user to upload some files, i connected the button to a database. But the problem is if i connect the button to image field, the user cannot upload a document and vice versa.
I have a simple idea: check the type of file before the information add to the database. Let say connect the file to a field call “submit” , then check if it is an image folder, insert it in the field “image”.
Is it a possible working method for it?
As my coding is very bad, i cannot find any solution even look at the whole wix
Here is my code(of course it can’t not work)

export function guestquestion_beforInsert(item) {
let myType = $w(item).type();
if (myType === “image”) {
item.image = ‘${item.submmitted}’;
}
if (myType === “document”){
item.document = ‘${item.submmitted}’;
}
item.remove();
}

Thank you for your helping.

Hi,
Maybe you should try a different approach, you can simply attach two upload buttons, one connected to an image field and the other to a document field, describe the use of each one of them and from there the upload will function as you wish.

Good luck :slight_smile: