# Saving form with document upload is not working

**URL:** <https://forum.wixstudio.com/t/saving-form-with-document-upload-is-not-working/56613>\
**Category:** Ask the community\
**Tags:** wix-dataset, code, question\
**Created:** [February 22, 2024, 11:52am UTC](https://forum.wixstudio.com/t/saving-form-with-document-upload-is-not-working/56613 "2024-02-22T11:52:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user1567](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/user1567/32/82452_2.png) [@user1567](https://forum.wixstudio.com/u/user1567)\
**Post date:** [February 22, 2024, 11:52am UTC](https://forum.wixstudio.com/t/saving-form-with-document-upload-is-not-working/56613/1 "2024-02-22T11:52:17Z")

</div>

**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:

```javascript
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);
    }
});

```

---

<div class="post-metadata">

**Author:** ![anthony](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/anthony/32/79536_2.png) [@anthony](https://forum.wixstudio.com/u/anthony)\
**Post date:** [February 23, 2024, 7:34pm UTC](https://forum.wixstudio.com/t/saving-form-with-document-upload-is-not-working/56613/2 "2024-02-23T19:34:57Z")

</div>

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

Also some things to check:

- Are the write permissions allowing for [anyone or site members](https://support.wix.com/en/article/cms-collection-permissions-overview#roles) to write? And if it’s site members are they logged in?
- Is the document being uploaded too large? Items (ie. rows) are currently limited to 500kb each but there is [a roadmap request to increase this](https://support.wix.com/en/article/cms-request-increasing-the-total-field-storage-limit-for-an-item-in-a-collection) which you can vote on.
  - In this case you can use the [media manager on the backend](https://www.wix.com/velo/reference/wix-media-backend/mediamanager-obj/upload) and a [Velo Web Method](https://dev.wix.com/docs/develop-websites/articles/coding-with-wix-studio/wix-studio-about-web-methods) to expose it to the frontend.
