Q:

CodeIgniter Upload File Ajax not working

No matter what I do I can't seem to get a file to upload via AJAX to CodeIgniter method. It always throws and never sees an uploaded file.
HTML
<div>
    <h1>Upload Your Translation</h1>
</div>

<form method="POST" class="myForm" enctype="multipart/form-data">
        <!-- add your span and pther stuff here-->
        <input type="file" id="foto1" name="userfile" />
        <input type="button" value="submit" onclick="submitFile();" />
</form>

<script>

function submitFile(){
        var formUrl = "/system_administration/AJAX_upload_translation";
        var formData = new FormData($('.myForm')[0]);

        $.ajax({
                url: formUrl,
                type: 'POST',
                data: formData,
                mimeType: "multipart/form-data",
                contentType: false,
                cache: false,
                processData: false,
                success: function(data, textSatus, jqXHR){
                        //now get here response returned by PHP in JSON fomat you can parse it using JSON.parse(data)
                },
                error: function(jqXHR, textStatus, errorThrown){
                        //handle here error returned
                }
        });
}

</script>

PAYLOAD
Request Method:POST
Status Code:200 OK
    ------WebKitFormBoundaryvkN2BT8ZDxXmKj7Y
    Content-Disposition: form-data; name="userfile"; filename="clippy-windows-8-10.jpg"
    Content-Type: image/jpeg

function AJAX_upload_translation()
    {
        if (!isset($_FILES['userfile']['error']) || is_array($_FILES['userfile']['error'])) 
        {
            throw new RuntimeException('Invalid parameters.');
        }

    }

A:

Try this code..
$('#upload').on('click', function() {
    var file_data = $('#foto1').prop('files')[0];   
    var form_data = new FormData();                  
    form_data.append('file', file_data);
    $.ajax({
            url: 'your_upload_php_file', // point to server-side PHP script 
            dataType: 'text',  // what to expect back from the PHP script, if anything
            cache: false,
            contentType: false,
            processData: false,
            data: form_data,                         
            type: 'post',
            success: function(php_script_response){
                alert(php_script_response); // display response from the PHP script, if any
            }
     });
});

