const uploadFile = (form) => {
    activeLoader();

    $.ajax({
        url: form.attr('action'),
        type: 'POST',
        data: new FormData(form[0]),
        processData: false,
        contentType: false,
        success: (data) => {
            window.location = data.redirectRoute;
        },
        error: (response) => {
            const data = response.responseJSON

            if (data.validation === 'file') {
                $('#file-wrapFILE').addClass('error white-tooltip');
                $('<span class="error">'+data.error+'</span>').appendTo('#errors');
            }
            if (data.validation === 'content') {
                desactivePopup();
                activePopup(data.title, data.html, 'modal_small');

                if (data.type === 'nonBloquant') {
                    document.querySelector('[data-popupwarning-ignore]').addEventListener('click', () => {
                        form.find('input[name="confirm"]').val(1);
                        uploadFile(form);
                        desactivePopup();
                    });
                }
            }

            desactiveLoader();
        }
    });
}