Welcome Guest, Not a member yet? Register   Sign In
update image
#1

[eluser]anyamanggar[/eluser]
hi guys, i have a lilte problem in update image file. The Case is when i want to update image i have finish upload but evertything id what i post is same with other, please help me..

Code:
function editgambarberita() {
        if ($_FILES) {
        
  $config = array(
  'upload_path' => 'images/uploads/berita/',
        'allowed_types' => 'gif|jpeg|jpg|png',
        'max_size' => '5120' // 5MB
  );

        $this->load->library('upload', $config);
        $this->upload->initialize($config);
  if ($this->upload->do_upload()) {
        $data = array(
        'upload_data' => $this->upload->data()
        );
                
        $file_name = $data['upload_data']['file_name'];
        $save['img_path'] = $file_name;}
        $this->load->model('news_model');
        $this->news_model->updategbr($save['file_name']);
  }
      if($_POST != NULL) {
        redirect('news_admin');
        }
  $this->load->view('admin/gantigambarberita_view');
  }

my model

Code:
function updategbr($data) {
       $this->db->update('news',$data);
    }
#2

[eluser]marjune[/eluser]
where did you save your image file? is it in directory or in db?
#3

[eluser]Sanjay Sarvaiya[/eluser]
you have to pass data array with key and value where key as a table field and value as a field value.
in your code you
Code:
$save['file_name'] = $file_name;
$this->news_model->updategbr($save);
#4

[eluser]anyamanggar[/eluser]
[quote author="Sanjay Sarvaiya" date="1341897353"]you have to pass data array with key and value where key as a table field and value as a field value.
in your code you
Code:
$save['file_name'] = $file_name;
$this->news_model->updategbr($save);
[/quote]

if i have 2 post article with images, when i used thad script i have finished but 2 post have same images.. ?? still not work i have
#5

[eluser]Sanjay Sarvaiya[/eluser]
please paste your view code.




Theme © iAndrew 2016 - Forum software by © MyBB