0

I am using ajax with codeigniter to submit a form including image data. problem is controller showing some error like "Disallowed Key Characters". i already changed the config file. but still its not working. please help me to solve this.

Ajax call:

$("form#wall_add").submit(function() {
      var m_data = new FormData();   
        m_data.append( 'id', $('input[name=id]').val());
        m_data.append( 'desc', $('input[name=desc]').val());
        m_data.append( 'notify', $('input[name=notify]').val());
        m_data.append( 'dcrp', $('textarea[name=dcrp]').val());
        m_data.append( 'img', $('input[name=post]')[0].files[0]);

       $.ajax({
          url: '<?php echo base_url();?>controller/method/',
          data: m_data,
          mimeType: "multipart/form-data",
          contentType: false,
          processData: false,
          type: 'POST',
          success: function(result)
                   {
                    $('#posts').html(result);
                    }
    });
    });

contoller:

public function method(){

           $data['added_content'] = $this->model->ins(); 
           $this->load->view('ajax_get_added',$data);
 }

Model :

   date_default_timezone_set('Asia/Calcutta');
    $date   = date("Y-m-d H:i:s", time());
    $fid    = $this->input->post('id');
    $desc   = $this->input->post('dcrp');
    $dtl    = $this->input->post('desc1');
    $notify = $this->input->post('notify');
    $this->load->helper('date');

        $config['upload_path'] = './img/post_images/family/';
        $config['allowed_types'] = 'gif|jpg|png|jpeg|';
        $this->load->library('upload', $config);
        $this->upload->initialize($config);
        $field_name ="img_post";
        $rgpic="0";
        if ( !$this->upload->do_upload($field_name))
        {
        $error = $this->upload->display_errors();
        $data['error']=$error;
        }
        else
        {
        $data = $this->upload->data();
        $regpicname=$data['file_name'];
        $rgpic="1";
        }
        if($rgpic!=0)
        {
        $data = array('date'=>$date,
                      'status'=>'A',
                      'img'=>'img/post_images/family/'.$regpicname,
                      'desc'=>$desc.$dtl,
                      'id'=>$fid,
                      'notify'=>$notify
                      );
                  }
        else{
        $data = array(
                      'date'=>$date,
                      'status'=>'A',
                      'desc'=>$desc.$dtl,
                      'id'=>$fid,
                      'notify'=>$notify
                    );
                    }   
user5060801
  • 67
  • 1
  • 2
  • 13

2 Answers2

0

try adding a cookie prefix in the config.php

$config['cookie_prefix'] = 'im_';
Dray
  • 887
  • 8
  • 25
0

Once you have found out what Characters is missing you then can add it here

application > config > config.php

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-&=?';

Around line 163

Hope this helps.

With your url on ajax try with out the base_url()

url: 'controller/method/',