0

如何使用内部图像编辑此数据。当我按下“提交”按钮时,数据已更新,但旧图像不能随新图像更改

if($this->input->post('go_upload'))
{
validation.......




$IdPerumahan = $this->uri->segment(3);

        if ($this->form_validation->run() == TRUE)
        {
            $lokasi_file = $_FILES['userfile']['tmp_name'];
            $nama_file = $_FILES['userfile']['name'];
            $ukuran_file = $_FILES['userfile']['size'];
            $direktori_file = "./images/$nama_file";

            if (empty($lokasi_file)) 
            {
                $this->load->model('PerumahanMDL');
                $this->PerumahanMDL->SimpanUbahPerumahan($IdPerumahan); 
                redirect('PerumahanCON');

            } else
            {
                $config['upload_path'] = './images/';
                $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg|png';
                $config['max_size'] = '2000';
                $config['overwrite'] = 'true';
                $config['max_width'] = '1024';
                $config['max_height'] = '768';

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

                $field_name = "userfile";
                if(!$this->upload->do_upload("userfile"))
                { 
                    $data['data']= 'TambahPerumahanVW';
                    $this->load->view('Desain2',$data);

                }else
                {

                            $asdf = $this->upload->data();
                            $config = array(
                                'source_image' => $asdf['full_path'],
                                'new_image' => './images/thumb',
                                'maintain_ration' => true,

                                'width' => 180,
                                'height' => 120
                        );
                        $this->load->library('image_lib', $config);
                        $this->image_lib->resize();

                        $userfile = $_FILES['userfile']['name'];    
                        $this->load->model('PerumahanMDL');
                        $this->PerumahanMDL->UbahDataPerumahan($userfile,$IdPerumahan); 

                        redirect('PerumahanCON');

                }
            }

        }
        }
}
4

1 回答 1

0

添加overwrite = true.

$this->load->library('upload', $config);
$this->upload->overwrite = true;
于 2013-12-19T02:33:41.840 回答