WordPress.org

Ready to get started?Download WordPress

Forums

wordpress file upload with ajax when site is using AJAX PAGE LOADER (2 posts)

  1. naresh.kumar
    Member
    Posted 1 year ago #

    I am getting problem in upload any file. My word press site is using [Ajax Page Loader] http://wordpress.org/extend/plugins/ajax-page-loader-15/ Plugin.So page is not refreshing when the form is submitting..

    I am not getting any value in PHP code in functions.php in **print_r($_FILES);**
    But i am printing any string with echo(); it is printing but why **print_r($_FILES);** is not getting any value.

    **HTML form**

    <form id="career_form" name="career_form" enctype="multipart/form-data">
        	<span id='errfrmMsg' style='margin:0 auto;'></span>
        	Upload : <input id="career_resume" class="field" style="height: 25px;" type="file" name="career_resume" multiple /></td>
        	<input type="hidden" name="action" value="career" />
        	<input id="submit_button" onclick="submit_career();" type="button" value="Send" />
        </form>

    **j Query**

    function submit_career()
        {
        	jQuery.post(the_ajax_career.ajaxurl_career,
        		jQuery("#career_form").serialize(),
        			function(response_from_the_action_function){
        				jQuery("#errfrmMsg").html(response_from_the_action_function).css({"display":"block"});
        			}
        		);
        }

    **Php code in functions.php**

    `wp_register_script("ajax-career", get_bloginfo('template_directory')."/js/custom_js.js", array( "jquery"));
    wp_enqueue_script('ajax-career');
    wp_localize_script("ajax-career","the_ajax_career", array("ajaxurl_career" => admin_url("admin-ajax.php")));
    // add actions
    add_action( "wp_ajax_career", "ajax_action_career" );
    add_action( "wp_ajax_nopriv_career", "ajax_action_career" );

    function ajax_action_career(){

    //Nothing getting in this print_r($_FILES) function;

    foreach ($_FILES["career_resume"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
    $name = $_FILES["career_resume"]["name"][$key];
    move_uploaded_file( $_FILES["career_resume"]["tmp_name"][$key], "uploads/" . $_FILES['career_resume']['name'][$key]);
    }
    }
    }
    `


    [Please use the code buttons when posting code]

  2. Zam
    Member
    Posted 7 months ago #

    it is the .serialize() which is creating problem, because it convert the form data into string, thats why $_FIELS doesnt contain anything.

Topic Closed

This topic has been closed to new replies.

About this Topic