title: Codeigniter CSRF valid for only one time ajax request
body: <p>I want to upload image on the server on change event of jQuery but using codeigniter csrf I am able to upload image only one time. How can I upload images using ajax for multiple requests.Please keep in mind when I set this</p>
  <pre><code>config['csrf_protection'] = FALSE;
  </code></pre>
  <p>then I am able to send multiple request jQuery onchange event but when csrf_protection is going to be false then I think there is no advantage of csrf. so the question is how can I send multiple requests using ajax while csrf_protection is enable. My jquery code is following</p>
  <pre><code>$(&quot;#avatar&quot;).change(function(){
      var link = $(&quot;#avatar&quot;).val();     
      $.ajax({
          url : &quot;&lt;?php echo base_url('main/test'); ?&gt;&quot;,
          type: 'post',
          data: {'&lt;?php echo $this-&gt;security-&gt;get_csrf_token_name(); ?&gt;':'&lt;?php echo $this-&gt;security-&gt;get_csrf_hash(); ?&gt;',&quot;id&quot;:&quot;hello&quot;,&quot;link&quot;:link},            
          success : function(data)
          {   
              alert(data);
          }  
      });
  });
  </code></pre>
  <p>My controller:</p>
  <pre><code>public function test()
  {
      $config['upload_path'] = './uploads/';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size'] = 500;
      $config['max_width'] = 260;
      $config['max_height'] = 260;
      $this-&gt;load-&gt;library('upload', $config);
      if (!$this-&gt;upload-&gt;do_upload('link')) {
          echo &quot;error&quot;;
      } else {
          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
          $image_name = $data['upload_data']['file_name'];
          echo $image_name;
      }
  }
  </code></pre>