Upload gallery with many images

I followed various examples and tutorials. After days of testing I was able to write a code that visually loads more images in a gallery on the page, but when I go to save the photos in the dbms, instead of recording them all in the gallery field of the database it writes them in a different field generating many record how many images.

Can anyone please tell me how can I fix it?

Thanks in advance as always


export function uploadgallery_change(event, $w) {

if ($w(“#gallery1”).items.length > 0) {
if ($w(“#gallery1”).items[0].title === “noImageUploadedImage”) {
let items = $w(“#gallery1”).items;
items.splice($w(“#gallery1”).items[0], 1);
$w(“#gallery1”).items = items;
}
}
$w(“#gallery1”).show();
let selectedFile = $w(“#uploadgallery”).value;
$w(“#textgallery”).hide();
$w(“#uploadgallery”).startUpload($w(“#uploadgallery”).buttonLabel = “In caricamento”)
.then((uploadedFile) => {
let uploadfileurl = uploadedFile.url;
let items = $w(“#gallery1”).items;
items.push({
“src”: uploadfileurl,
});
$w(“#gallery1”).items = items;
$w(“#uploadgallery”).reset();
$w(“#uploadgallery”).buttonLabel = “caricato”;
$w(“#deletebutton”).show();
wixData.insert(“test”, uploadedFile);
})
. catch ((uploadError) => {
console.log(Error: ${uploadError.errorCode});
$w(“#uploadgallery”).reset();
$w(“#uploadgallery”).buttonLabel = “caricamento”;
$w(“#textgallery”).text = “File non supportato”;
$w(“#textgallery”).show();
});
}


Are you talking about trying to save your images in the media gallery images field?

https://support.wix.com/en/article/displaying-media-uploaded-in-your-media-gallery-field-type

As for the images going into the URL field and not image field, well that is how upload button works.

First part is to get the users image and upload it, then the second part is to provide you with the URL link to it.

See the links below the picture for more info about it.

Same if you checked the upload button yourself manually through the get file button, it goes to the image via the URL link for it.

https://www.wix.com/corvid/reference/$w.UploadButton.html

https://support.wix.com/en/article/wix-code-using-the-upload-button-with-code

Also, see this post here too.
https://www.wix.com/corvid/forum/community-discussion/getting-url-of-an-image-that-has-been-uploaded-by-a-member-http-request?ref=producthunt%2F%2F%2F%2F%2F%2F%2F

hi @givemeawhisky
I had already seen the information you gave me. Unfortunately, they don’t concern my problem.
I ask you, please, to try to use my code and simulate the situation so as to better understand the error it generates.
In fact I think it is of interest to many other users.

I’m simply trying to upload images to the gallery. The upload button works. on the page the gallery images appears, they are also save in the DB, but instead of images they are saved as an address, in a different field.

can you help me?