文件未存储在正确的文件夹中

Files not getting stored in correct folder

我在 CodeIgniter 中有一个表单,允许用户上传 2 个单独的文件。在后端,我希望这些文件存储在不同的文件夹中。在控制器中我写了上传代码

public function upload()
    {
        /**Start uploading file**/
        $config['upload_path'] = './assets/file/.';
        $config['allowed_types'] = 'gif|jpg|png|doc|txt';
        $config['max_size'] = 1024 * 8;
        $config['encrypt_name'] = TRUE;

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload('file')) 
            {
              $error = array('error' => $this->upload->display_errors());
              echo $error;

            }
        else
            {
              $data = $this->upload->data();
              echo $file = $data['file_name']; //name of  file

            }

        /**End uploading file**/

        /**Start uploading img**/

        $config2['upload_path'] = './assets/img/.';
        $config2['allowed_types'] = 'gif|jpg|png|doc|txt';
        $config2['max_size'] = 1024 * 8;
        $config2['encrypt_name'] = TRUE;

        $this->load->library('upload', $config2);

        if (!$this->upload->do_upload('img')) 
            {
              $error1 = array('error' => $this->upload->display_errors());
              echo $error1;

            }
        else
            {
              $data1 = $this->upload->data();
              echo $img = $data1['file_name']; //name of  img

            }

        /**End uploading img**/
    }

图像正在上传,但它们正在上传到同一文件夹。谁能告诉我如何让文件保存在单独的文件夹中

第二次加载时,需要对加载的库进行初始化,因为加载方法没有初始化:

$this->upload->initialize($config2);