Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

WordPress ajax file upload

jQuery(document).on('click', '#submit', function(e){
    e.preventDefault();

    var fd = new FormData();
    var file = jQuery(document).find('input[type="file"]');
    var caption = jQuery(this).find('input[name=img_caption]');
    var individual_file = file[0].files[0];
    fd.append("file", individual_file);
    var individual_capt = caption.val();
    fd.append("caption", individual_capt);  
    fd.append('action', 'fiu_upload_file');  

    jQuery.ajax({
        type: 'POST',
        url: fiuajax.ajaxurl,
        data: fd,
        contentType: false,
        processData: false,
        success: function(response){

            console.log(response);
        }
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: JavaScript HTML DOM - Changing CSS 
Javascript :: JavaScript HTML DOM Changing HTML Style 
Javascript :: laravel array to js 
Javascript :: js string contains 
Javascript :: diff two arrays javascript 
Javascript :: create react portal 
Javascript :: react native change app name 
Javascript :: change no to string in js 
Javascript :: js get random hex color 
Javascript :: activeclassname in react router v6 
Javascript :: use js to save data in laravel using route 
Javascript :: js enums class 
Javascript :: laravel jquery csrf 
Javascript :: To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. 
Javascript :: regex separator 
Javascript :: add property to object conditionally 
Javascript :: Glide Ajax Client Script ServiceNow 
Javascript :: typeorm get data from a table by array of id 
Javascript :: file picker electron 
Javascript :: duplicate value removed in array of object in javascript 
Javascript :: when a form is subbmited jquery 
Javascript :: npm ERR! code EJSONPARSE 
Javascript :: calculate today date javascript 
Javascript :: Write the JavaScript code to set the width of element to 50%; 
Javascript :: change alt text javascript 
Javascript :: js add class 
Javascript :: javascript element in array 
Javascript :: contenteditable paste plain text 
Javascript :: javascript object filter 
Javascript :: ngx toastr 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =