View code
<form id="form1" method="post" enctype="multipart/form-data" action='<?php echo base_url();?>index.php/setup_con/upload'>
<input type="file" name="userfile" id="userfile" required="required"/>
</form>
<form id="form2" method="post"  enctype="multipart/form-data" action='<?php echo base_url();?>index.php/setup_con/register'>
<input type="text" name="name" id="name"/> 
<input type="text" name="city" id="city"/> 
<input type="text" name="mobile" id="mobile"/> 
<input type="submit" value="Submit" />
</form>
controller code
function upload()
{
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '800';
    $config['max_width']  = '1024';
    $config['max_height']  = '768';
    $this->load->library('upload', $config);
    if (!$this->upload->do_upload())
    {
        echo "File is Not valid/File does not select";
        $error = array('error' => $this->upload->display_errors());
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());
        $img_name =  $data ['upload_data']['file_name'];
            echo "'<img src='".base_url()."uploads/".$img_name."' class='preview'>";
    }
}
    function register()
    {
        $this->form_validation->set_rules('name','Name', 'trim|required');
        $this->form_validation->set_rules('city','city', 'trim|required');
        $this->form_validation->set_rules('mobile','mobile', 'trim|required');
        if($this->form_validation->run() == FALSE)
    {
        }
        else
        {
           $data = $this->register_model->register();
        }
    }
I have upload image from first form using ajax in codeigniter which controller is upload,here will be upload only image this controller but i would like to image name to send register controller which i will insert image_name, name, city and monbile in resister table.
Please help me,
How can i do it successfully
 
     
     
    