Upload blob on server with ajax-Collection of common programming errors

Can anyone tell me how I can store a blob on the server with an ajax call? I have tried many things but none of them work. And I cannot find any good information about this.

This is where I want to send the blob

class Ajax extends CI_Controller {

function __construct()
{
    parent::__construct();
    $this->load->helper('url');
    $this->load->helper('form_helper');
    $this->load->library('tank_auth');

}

public function saverecording()
{
    $status = "";
    $msg = "";
    $file_element_name = 'komaan';
    if ($status != "error")
    {
          $config['upload_path'] = '../../upload/audio/recordings/';
          $config['allowed_types'] = 'wav';
          $this->load->library('upload', $config);
          if (!$this->upload->do_upload($file_element_name))
          {
             $status = 'error';
             $msg = $this->upload->display_errors('', '');
             echo '
             console.log("this is not working");';
          }
          else
          {
             $data = $this->upload->data();
             echo '
             console.log("this is ");';
             //$file_id = $this->files_model->insert_file($data['file_name'], $_POST['title']);
          }
          @unlink($_FILES[$file_element_name]);
       }
}

NEW EDIT: Thanks for your patience, I’m pretty new with web development. I figured out what the problem is. As I said I get a blob file from javascript code:

recorder.exportWAV(function(blob) {
            console.log(blob);
            $('userfile').val(blob);
            $.ajaxFileUpload({
            url :  "../ajax/saverecording/", 
            secureuri      :false,
            fileElementId  :'userfile',
                dataType : blob.type,
                data: blob,
                success: function(data, status) {
                    if(data.status != 'error')
                        alert("hoera!");
                    alert(data.msg);
                }
            });
        });

The $(‘userfile’).val(blob); gives me a “Uncaught Error: InvalidStateError: DOM Exception 11 ” Why?

Thanks

Katrijne

Originally posted 2013-11-15 09:07:17.