0

I make file uploading in WordPress using $.post(), i not use $.ajax() because not working on Chrome for Android 4, so i use $.post().

But problems here, i can't handle file upload use$.post(), only give an error TypeError: 'slice' called on an object that does not implement interface Blob.

This my code.

<input type="file" id="attachment-upload" name="attachment-upload" multiple />

// start uploading
$( document ).on( 'change', '#attachment-upload', function(e) {
    // get file
    var file = e.target.files;

    var ajax_data = {
        action: 'upload_new_attachment',
        file: file,
    }

    // ajax actions
    $.post( ajaxurl, ajax_data, function( response ) {
        console.log(response);
    }, 'json' );
});

In another tutorial i see use $.ajax() with setting processData: false and contentType: false.

Now, how put setting processData: false and contentType: false for $.post().

Thanks.

Opsional
  • 543
  • 4
  • 14

0 Answers0