# File Upload

If you want to add this kind of field to your form, you'll need to modify the code sending script.

```
<input type="file" name="file">
```

Imagine you have an ajax code witch looks like this one: &#x20;

```javascript
$("#my-form").submit(function() {
    const $form = $(this);
    let options = {
        type: 'POST',
        url: _dynamic_base + '/lead/' + window.websiteID,
        data: $form.serialize(),
    };

    $.ajax(options)
    .then(function(data) {
        console.log("data", data)
    })
});
```

In the case where the user uploaded files, you'll need to add them to the form data. To do that, please add some code to the ajax script:&#x20;

```javascript
$("#my-form").submit(function() {
    const $form = $(this);
    let hasFiles = 0;
    let $fileInputs = $(this).find('input[type="file"]');
    let options = {
        type: 'POST',
        url: _dynamic_base + '/lead/' + window.websiteID,
        data: $form.serialize(),
    };
    
    $fileInputs.each(function(index) {
        if(this.files.length) return hasFiles = 1;
    });

    if(hasFiles) {
        options.data = new FormData($form[0]);
        options.cache = false;
        options.contentType = false;
        options.processData = false;
    }    

    $.ajax(options)
    .then(function(data) {
        console.log("data", data)
    })
});
```

{% hint style="info" %}
To verify everything is ok, inside the Website BO, go to **Leads > Lead Edit > Lead Document** and check that all uploaded files are here.
{% endhint %}
