hi guys as above ive tried everything, i set the let toInsert = to the dynamic dataset on the page but it only uploads text and not the images and documents etc?
i tried altering this code from elsewhere on the forum but had no joy, because its only set for one upload file button, thanks in advance for anyone who can help me on this
import wixData from 'wix-data';
import wixLocation from 'wix-location';
export function uploadButton3_change(event) {
let file = $w("#uploadButton3").value[0].name;
$w("#text26").text= String(file);
}
export function button1_click_1() {
if($w("#uploadButton3").value.length > 0) { //run only if a document is uploaded
$w("#button1").disable();
$w("#button1").label = 'Please wait...';
$w("#uploadButton3").startUpload()
.then( (uploadedFile) => {
let fileLocation = uploadedFile.url;
insertData(fileLocation);
});
} else {
$w("#button1").label = 'Please upload file';
}
}
function insertData(fileLocation) {
let toInsert = {
"repeater_file1": fileLocation, //make sure that repeater_file1 is a document field in the database
"repeaterFile1Title": $w("#text26").text,
"repeater_date": $w("#datePicker1").value,
"repeater_title": $w("#inputTitle").value,
"repeater_description": $w("#textDescription").value,
};
wixData.insert("Announcements", toInsert) //name of the database
.then(() => {
wixLocation.to("https://www.blank.com/announcements"); //this is where your user will be redirected after the file upload so enter a proper URL
});
}
Hi 🖐
See my answer here:
https://www.wix.com/corvid/forum/main/comment/5ef24fd4caff62002dd6f1e7
Also, read about uploading files here.
https://www.wix.com/corvid/new-reference/$w/uploadbutton/startupload