Hello all
i have 3 user input elements
1- text box for name
2- text for phone number
3- upload element for upload image called uploadButton
upload photo does not work properly
i have this code below :
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
//TODO: write your page related code here...
});
export function submit_form(event, $w) { //Add your code for this event here: if ($w("#uploadButton").value.length > 0) { // user chose a file console.log(`Uploading '${$w("#uploadButton").value[0].name}'`); $w("#uploadButton").startUpload() .then( (uploadedFile) => { console.log("Upload successful. File is available here:"); console.log(uploadedFile.url); } ) .catch( (uploadError) => { console.log(`File upload error: ${uploadError.errorCode}`); console.log(uploadError.errorDescription); } ); } else { // user clicked button but didn't chose a file console.log("Please choose a file to upload.") } $w('#imgLoader').show() // "yourGif" refers to preloader gif setTimeout(() => { const nameInputValue = $w('#nameInput').value; const PhoneInputValue = $w('#phoneNumber').value; const UploadInputValue = $w('#uploadButton').value; const toInsert = { name: nameInputValue, phoneno: PhoneInputValue, photo: UploadInputValue, } wixData.insert('test',toInsert) .then(() => { $w('#imgLoader').hide() wixLocation.to('Thank Yout Page') }) },2000); // set the time to preform the insert method. 2000ms }