title: How to send an image and other form data in controller in codeigniter using ajax
body: <p>here is my ajax call i am uploading an image using ajax. i want to send a text box data with image file. How it will possible in this function? Here is my function and ajax call</p>
  
  <pre><code> function updateSpeciality(id)
      {
       var name = $("#speciality").val();
       var form_data=new FormData();
       $.each($("#myfile")[0].files,function(i,file){
         form_data.append("image",file);
       });
       $.ajax({    
          url:"&lt;?php echo base_url('Dashboard/saveSpeciality');?&gt;",
          type:'POST',
          cache:false,
          async:false,
          contentType:false,
          processData:false,
          data:form_data,
          success:function(data){
            alert("i am in success");
          },
          error:function(error){
            alert("i am fail");
          }
       });
      }
  </code></pre>
  
  <p>i want to send value of var name with file as well to my controller function. Because in controller function i am saving name and file path in db. ajax call is going perfect but how will i send name value in this data ?</p>