如果我已有一个表格,如何在Codeigniter中上传图像?

My question is that how can I upload image if I already have a form?

I would like to upload with only one button click.

    <form class="form-horizontal" role="form" method="post" action="/controller/method">
    <div class="form-group">
        <label for="test" class="col-xs-8 control-label">Test:</label>
        <div class="col-xs-8">
            <input type="text" class="form-control" id="test" name="test" placeholder="" value="">
        </div>
    </div>
    <div class="form-group">
        <label for="file" class="col-xs-8 control-label">File:</label>
        <div class="col-xs-8">
            <input type="file" id="file" name="file" class="file">
        </div>
    </div>

This is only post the selected file name. I have to validate every input and if there is a way I do not want to create new controller function.

Using this coding u can upload the file[view]

<div class="form-group">

                                            <label for="exampleInputFile">Image Upload</label>

                                            <input id="myfile" name="myFile" type="file" />
                                            <label id="upload-error" style="color:red;display: none;">Choose File</label>

                                        </div>

For controller

if($this->input->post('select'))
                    { 
                       $image=array();
                       $image_title=  $this->input->post('title');
                            $folder="./img/uploadimg/";
                            if(is_uploaded_file($_FILES['myFile']['tmp_name']))
                            {
                            if(copy($_FILES['myFile']['tmp_name'],$folder.$_FILES['myFile']['name']))
                            {
                                $source= $folder.$_FILES['myFile']['name'];
                                $source_image=$_FILES['myFile']['name'];
                                $img_path=explode(".", $source_image);
                            }
                            $image['filepath']=$source;
                            $image['filename']=  $this->input->post('title');
                            }