upload gambar tidak terupdate dan tidak ada perintah error tetapi sukses

 public function edit()
    {
        $this->form_validation->set_rules('username', 'Full name', 'required|trim');
        $this->form_validation->set_rules('address', 'Address', 'required|trim');
        if ($this->form_validation->run() == false) {
            $data = array(
                'title'          => 'Edit Profile',
                'titelbar'       => 'WEB SHS',
                'isi'            => 'user/edit'
            );
            $data['user'] = $this->db->get_where('user', ['email' =>
            $this->session->userdata('email')])->row_array();
            $this->load->view('admin/layout/v_wrapper', $data);
        } else {
            $username = $this->input->post('username');
            $address = $this->input->post('address');
            $email = $this->input->post('email');
            //jika ada gambar yang di upload
            $upload_image = $_FILES['image']['name'];
            if ($upload_image) {
                $config['allowed_types'] = 'jpg|png';
                $config['max_size']     = '2048';
                $config['upload_path'] = './assets/img/profile/';

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

                if ($this->upload->do_upload('image')) {
                    $old_image = $data['user']['image'];
                    if ($old_image != 'default.jpg') {
                        unlink(FCPATH . 'assets/img/profile/' . $old_image);
                    }
                    $new_image = $this->upload->data('file-name');
                    $this->db->set('image', $new_image);
                } else {
                    echo $this->upload->display_errors();
                }
            }
            $this->db->set('username', $username);
            $this->db->set('address', $address);
            $this->db->where('email', $email);
            $this->db->update('user');
            $this->session->set_flashdata('massage', '<div class="alert alert-success" role="alert">
       Youre profile has bend update!</div>');
            redirect('user');
        }
    }
avatar pheotofficial_google
@pheotofficial_google

1 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>itu sistem cache server, default nya biasa nya 7 hr<br><br>agar tampilan terupdate maka pada html mesti tiambah parameter file dinamik<br><br>misal pada html nya:<br><br></div><pre>&lt;img src="upload/img/filegambar1.jpg"&gt;</pre><div><br><br>dirubah menjadi<br><br></div><pre>&lt;img src="upload/img/filegambar1.jpg?t=xx"&gt;</pre><div><br>dimana xx bisa diganti ganti, yg paling baik ada filetime nya diambil dari php code:<br><br></div><pre>filemtime("upload/img/filegambar1.jpg");</pre><div><br></div><div>jadi codingnya:</div><pre>&lt;?php $jamfile=filemtime("upload/img/filegambar1.jpg");<br>echo "&lt;img src='upload/img/filegambar1.jpg?t=$jamfile'&gt;";?&gt;</pre>

avatar gurukoding
@gurukoding

20 Kontribusi 8 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban