Uploading an image as featured image from frontend form

I have found the problem.

Problem was in a .js file. This code is causing the problem :

$et_contact_form.live('submit', function() {
    et_contact_error = false;
    et_message="<ul>";

    $et_inputs.removeClass('et_contact_error');

    $et_inputs.each(function(index, domEle){
        if ( jQuery(domEle).val() === '' || jQuery(domEle).val() === jQuery(this).siblings('label').text() ) {
            jQuery(domEle).addClass('et_contact_error');
            et_contact_error = true;

            var default_value = jQuery(this).siblings('label').text();
            if ( default_value == '' ) default_value = et_ptemplates_strings.captcha;

            et_message += '<li>' + et_ptemplates_strings.fill + ' ' + default_value + ' ' + et_ptemplates_strings.field + '</li>';
        }
        if ( (jQuery(domEle).attr('id') == 'et_contact_email') && !et_email_reg.test(jQuery(domEle).val()) ) {
            jQuery(domEle).removeClass('et_contact_error').addClass('et_contact_error');
            et_contact_error = true;

            if ( !et_email_reg.test(jQuery(domEle).val()) ) et_message += '<li>' + et_ptemplates_strings.invalid + '</li>';
        }
    });

    if ( !et_contact_error ) {
        $href = jQuery(this).attr('action');

        $et_contact_container.fadeTo('fast',0.2).load($href+' #et-contact', jQuery(this).serializeArray(), function() {
            $et_contact_container.fadeTo('fast',1);
        });
    }

    et_message += '</ul>';

    if ( et_message != '<ul></ul>' )
        $et_contact_message.html(et_message);

    return false;
})

And what is causing the trouble exactly :

if ( !et_contact_error ) {
        $href = jQuery(this).attr('action');

        $et_contact_container.fadeTo('fast',0.2).load($href+' #et-contact', jQuery(this).serializeArray(), function() {
            $et_contact_container.fadeTo('fast',1);
        });
    }

I think the fact that this javascript is refreshing the form without complete refresh page is causing that the file is not received by the server via POST methode

Am I right ?

Do you have any clue to solve the JS thing to include the file upload ?

Leave a Comment