Saving form with document upload is not working

Question:
I have created a multi-page form with a document upload on one page and a bunch of text fields on the next page. Each field is correctly linked to a corresponding field in a dataset I have created. The dataset has write permissions and the submit button has a submit action associated with it.

When I remove the upload part of the form it saves perfectly but when it is there it doesn’t save at all. It triggers the beforeSave hook and then never saves but also gives me no error.

Product:
Wix website editor

What are you trying to achieve:
Save the multipart form with the document input

What have you already tried:
I have tried manually inserting directly to the database which nearly worked but I couldn’t work out how to submit the actual file and not just a description of it.

If anyone has had a similar issue with using multi-part forms and document uploads then please let me know how you solved it. Example code would be great!

Additional information:
MY CODE:

const nextJobForm = $w('#nextJobForm');

// Your details page
const cvInput = $w('#uploadCV');
const firstName = $w('#inputFirstName');
const lastName = $w('#inputLastName');
const email = $w('#inputEmail');
const contactNumInput = $w('#inputContactNum');
const postcode = $w('#inputPostcode');
const primaryJobTitle = $w('#inputJobTitle');

// Buttons
const nextBut = $w('#nextButton');
const submitBut = $w('#buttonSubmit');
const backBut = $w('#buttonBack');
const homeBut = $w('#buttonHome');

const validateinputFunc = (selector) => {
    let i = 0;
    selector.onCustomValidation((value, reject) => {
        if (value.length <= 0) {
            reject("Company name is required");
            i = 0;
        } else {
            i ++;
        }
    });
    return i;
};


const clickNextForm = () => {
	cvInput.updateValidityIndication();

	let i = validateinputFunc(cvInput);

	console.log(i);
    i === 1 ? nextJobForm.changeState("contactInfoJob") : console.log('Some fields not valid');
};

const clickSubmitForm = () => {
    firstName.updateValidityIndication();
    lastName.updateValidityIndication();
    email.updateValidityIndication();
    contactNumInput.updateValidityIndication();
    postcode.updateValidityIndication();
    primaryJobTitle.updateValidityIndication();

    let i = 0;
    i = i + validateinputFunc(firstName);
    i = i + validateinputFunc(lastName);
    i = i + validateinputFunc(email);
    i = i + validateinputFunc(contactNumInput);
    i = i + validateinputFunc(postcode);
    i = i + validateinputFunc(primaryJobTitle);

    if (i === 6) {
        submitBut.label = 'Submitting...';
        backBut.disable();
    } else {
        console.log('Some fields not valid');
    }
};

$w.onReady(function () {
    try {
        nextBut.onClick(() => {
            clickNextForm();
        });

        backBut.onClick(() => {
            firstName.resetValidityIndication();
            lastName.resetValidityIndication();
            email.resetValidityIndication();
            contactNumInput.resetValidityIndication();
            postcode.resetValidityIndication();
            primaryJobTitle.resetValidityIndication();

            nextJobForm.changeState("enterCV");
        });
        
        //Submit
        submitBut.onClick(() => {
            clickSubmitForm();
        });

        $w("#dataset1").onBeforeSave( () => {
            console.log("Continuing save");
            return true;
        });
        $w('#dataset1').onAfterSave(() => {
            console.log('After save running');
            submitBut.label = 'Submit';
            nextJobForm.changeState("confirmationJob");
        });
    } catch(e) {
        console.log(e);
    }
});

Can you share the code that includes the upload/save part?

Also some things to check: