How to upload Document to Database with Wix Code

I have a form which submits data to a database with wix code.

One of the elements is a Document.

This is the code

 
async function apply() {
 var item = {
 "applicationFor": $w('#name').text,
 "applicationCountry": $w('#location').text,
 "applicantName": $w('#applicantName').value,
 "applicantPhoneNumber": $w('#phone').value,
 "applicantEmail": $w('#email').value,
 "applicantCv": $w('#cv').(), //this is the document
 "tC": $w('#checkbox1').value
                }

if ($w("#checkbox1").checked === false) {
    $w("#tcError").show();
    } else if ($w("#cv").value === null) {
    $w("#cvError").show()
    } else if ($w("#email").value === false) {
    $w("#emailError").show()
    } else if ($w("#cv").value === null) {
    $w("#cvError").show()
    } else {
            wixData.insert("Applicants", item)
                .then(() => {
 // show confirmation 
            wixWindow.openLightbox('Success');
           })
}}

I am not able to upload the document to the database. Does anyone know how to do it ?

Hi Shan,

uploading a document requires upload button to be uploaded, check out This to see how it work.

Good Luck,
Mustafa