Undefined property: ci_loader::$upload dan call to a member function library() on null

Ketika upload konfigurasi logo terjadi error. 1.ERROR PERTAMA Message: Undefined property: CI_Loader::$upload Filename: admin/Konfigurasi.php Line Number: 77 Backtrace: File: C:\xampp\htdocs\doodle\application\controllers\admin\Konfigurasi.php Line: 77 Function: _error_handler 2.ERROR KEDUA Message: Call to a member function library() on null Filename: C:\xampp\htdocs\doodle\application\controllers\admin\Konfigurasi.php Line Number: 77

CONTROLLER KONFIGURASI

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Konfigurasi extends CI_Controller{

	//Load model
	public function __construct()
  {
    parent::__construct();
    $this->load->model('konfigurasi_model');

  }

	//Konfigurasi Umum
  	public function index()
  	{
  		$konfigurasi	= $this->konfigurasi_model->listing();
  	//Validasi input

    $valid= $this->form_validation;

    $valid->set_rules('nama_web','Nama Website','required',
            array('required'    => '%s harus diisi'));

    if($valid->run()===FALSE) {
    //End validasi

    $data= array( 	'title'       => 'Konfigurasi Website',
    				        'konfigurasi' => $konfigurasi,
                  	'isi'         => 'admin/konfigurasi/list'
                );
    $this->load->view('admin/layout/wrapper', $data, FALSE);
    //Masuk database
    }else{
      $i             = $this->input;
      $data = array(  'id_konfigurasi' 	  	=> $konfigurasi->id_konfigurasi,
  	 					        'nama_web' 			     	=> $i->post('nama_web'),
                      'tagline' 			     	=> $i->post('tagline'),
                     	'email'        	  		=> $i->post('email'),
                     	'website' 			     	=> $i->post('website'),
                     	'keywords' 			    	=> $i->post('keywords'),
                      'telepon' 		    		=> $i->post('telepon'),
                      'alamat' 			      	=> $i->post('alamat'),
                     	'facebook' 		       	=> $i->post('facebook'),
                     	'instagram' 	     		=> $i->post('instagram'),
                     	'deskripsi' 		    	=> $i->post('deskripsi'),
                     	'rekening_pembayaran'	=> $i->post('rekening_pembayaran')
                    );
          $this->konfigurasi_model->edit($data);
          $this->session->set_flashdata('sukses', 'Data telah diupdate');
          redirect(base_url('admin/konfigurasi'),'refresh');
      }
      //End masuk database
  	}

  	//Konfigurasi logo website
  	public function logo ()
  	{
      $konfigurasi = $this->konfigurasi_model->listing();

      //Validasi input
      $valid    = $this->form_validation;

      $valid->set_rules('nama_web','Nama Website','required',
            array('required'  => '%s harus diisi'));

     if($valid->run()) {
        //Check jika logo diganti
        if(!empty($_FILES['logo']['name'])) {

        $config['upload_path']     = './assets/upload/image/';
        $config['allowed_types']   = 'gif|jpg|png|jpeg';
        $config['max_size']        = '2400'; //Dalam kb
        $config['max_width']       = '2024';
        $config['max_height']      = '2024';

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

      if ( ! $this->upload->do_upload('logo')){
      //End validasi

      $data= array( 'title'       => 'Konfigurasi Logo Website',
                  'konfigurasi'   => $konfigurasi,
                  'error'         => $this->upload->display_errors(),
                  'isi'           => 'admin/konfigurasi/logo'
                );
      $this->load->view('admin/layout/wrapper', $data, FALSE);
      //Masuk database
      }else{
         $upload_gambar = array('upload_data' => $this->upload->data());

          //Create thumbnail gambar
          $config['image_library']    = 'gd2';
          $config['source_image']     = './assets/upload/image/'.$upload_gambar['upload_data']['file_name'];
          //Lokasi folder thumbnail
         $config['new_image']        = './assets/upload/image/thumbs/';
         $config['create_thumb']     = TRUE;
         $config['maintain_ratio']   = TRUE;
         $config['width']            = 250;//dalam ukuran pixel
         $config['height']           = 250;
         $config['thumb_marker']     = '';

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

      $this->image_lib->resize();
      //End create thumbnail

      $i = $this->input;
      $data = array(  'id_konfigurasi'   => $konfigurasi->id_konfigurasi,
                      'nama_web'         => $i->post('nama_web'),
                      // Yang disimpan adalah nama file gambarnya
                      'logo'             => $upload_gambar['upload_data']['file_name']
                    );
          $this->konfigurasi_model->edit($data);
          $this->session->set_flashdata('sukses', 'Data telah diupdate');
          redirect(base_url('admin/konfigurasi/logo'),'refresh');
      }}else{
        //Edit produk tanpa ganti gambar
          $i = $this->input;
      $data = array(  'id_konfigurasi'   => $konfigurasi->id_konfigurasi,
                      'nama_web'         => $i->post('nama_web')
                      // Yang disimpan adalah nama file gambarnya
                      //'logo'             => $upload_gambar['upload_data']['file_name']
                    );
          $this->konfigurasi_model->edit($data);
          $this->session->set_flashdata('sukses', 'Data telah diupdate');
          redirect(base_url('admin/konfigurasi/logo'),'refresh');
      }}
      //End masuk database
      $data= array( 'title'       => 'Konfigurasi Logo Website',
                  'konfigurasi'   => $konfigurasi,
                  'isi'           => 'admin/konfigurasi/logo'
                );
      $this->load->view('admin/layout/wrapper', $data, FALSE);
  	}

  //Konfigurasi icon website
  public function icon()
  {
        $konfigurasi = $this->konfigurasi_model->listing();
      //Validasi input
      $valid    = $this->form_validation;

      $valid->set_rules('nama_web','Nama Website','required',
            array('required'  => '%s harus diisi'));

     if($valid->run()) {
        //Check jika logo diganti
        if(!empty($_FILES['icon']['name'])) {

        $config['upload_path']     = './assets/upload/image/';
        $config['allowed_types']   = 'gif|jpg|png|jpeg';
        $config['max_size']        = '2400'; //Dalam kb
        $config['max_width']       = '2024';
        $config['max_height']      = '2024';

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

      if ( ! $this->upload->do_upload('icon')) {
      //End validasi

      $data= array( 'title'       => 'Konfigurasi Icon Website',
                  'konfigurasi'   => $konfigurasi,
                  'error'         => $this->upload->display_errors(),
                  'isi'           => 'admin/konfigurasi/icon'
                );
      $this->load->view('admin/layout/wrapper', $data, FALSE);
      //Masuk database
      }else{
         $upload_gambar = array('upload_data' => $this->upload->data());

          //Create thumbnail gambar
          $config['image_library']    = 'gd2';
          $config['source_image']     = './assets/upload/image/'.$upload_gambar['upload_data']['file_name'];
          //Lokasi folder thumbnail
         $config['new_image']        = './assets/upload/image/thumbs/';
         $config['create_thumb']     = TRUE;
         $config['maintain_ratio']   = TRUE;
         $config['width']            = 250;//dalam ukuran pixel
         $config['height']           = 250;
         $config['thumb_marker']     = '';

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

      $this->image_lib->resize();
      //End create thumbnail

      $i = $this->input;
      $data = array(  'id_konfigurasi'   => $konfigurasi->id_konfigurasi,
                      'nama_web'         => $i->post('nama_web'),
                      // Yang disimpan adalah nama file gambarnya
                      'icon'             => $upload_gambar['upload_data']['file_name']
                    );
          $this->konfigurasi_model->edit($data);
          $this->session->set_flashdata('sukses', 'Data telah diupdate');
          redirect(base_url('admin/konfigurasi/icon'),'refresh');
      }}else{
        //Edit produk tanpa ganti gambar
          $i = $this->input;
      $data = array(  'id_konfigurasi'   => $konfigurasi->id_konfigurasi,
                      'nama_web'         => $i->post('nama_web')
                      // Yang disimpan adalah nama file gambarnya
                      //'icon'             => $upload_gambar['upload_data']['file_name']
                    );
          $this->konfigurasi_model->edit($data);
          $this->session->set_flashdata('sukses', 'Data telah diupdate');
          redirect(base_url('admin/konfigurasi/icon'),'refresh');
      }}
      //End masuk database
      $data= array( 'title'       => 'Konfigurasi Icon Website',
                  'konfigurasi'   => $konfigurasi,
                  'isi'           => 'admin/konfigurasi/icon'
                );
      $this->load->view('admin/layout/wrapper', $data, FALSE);
  	}

 }

KONFIGURASI MODEL

<?php
defined('BASEPATH') or exit ('No direct script access allowed');

class Konfigurasi_model extends CI_Model {

	public function __construct()
 	{
    	parent::__construct();
    	$this->load->database();
    }

    //Listing
    public function listing()
    {
    	$query = $this->db->get('konfigurasi');
    	return $query->row();
    }

    //Edit
    public function edit($data)
    {
    	$this->db->where('id_konfigurasi', $data['id_konfigurasi']);
    	$this->db->update('konfigurasi', $data);
    }

}

VIEWS KONFIGURASI/LOGO

<?php
//Notifikasi
If($this->session->flashdata('sukses')) {
  echo '<p class="alert-success">';
  echo $this->session->flashdata('sukses');
  echo '</div>';
}
?>

<?php
//Error upload
if(isset($error)) {
  echo '<p class="alert alert-warning';
  echo $error;
  echo '</p>';
}

//Notifikasi error
echo validation_errors('<div class="alerr alert-warning">','</div>');

//Form open
echo form_open_multipart(base_url('admin/konfigurasi/logo/'),' class="form-horizontal"');
?>

<div class="form-group">
  <label class="col-md-2 control-label">Nama website</label>
  <div class="col-md-5">
    <input type="text" name="nama_web" class="form-control" placeholder="Nama Website" value="<?php echo $konfigurasi->nama_web ?>" required>
  </div>
</div>

<div class="form-group">
  <label class="col-md-2 control-label">Upload logo baru</label>
  <div class="col-md-5">
    <input type="file" name="logo" class="form-control" placeholder="Upload Logo Baru" value="<?php echo $konfigurasi->logo ?>" required>
    Logo lama: <br>
    <img src="<?php base_url('assets/upload/image/'.$konfigurasi->logo) ?>" class="img img-responsive img-thumbnail" width="200">
  </div>
</div>

<div class="form-group">
  <label class="col-md-2 control-label"></label>
  <div class="col-md-5">
  <button class="btn btn-success btn-lg" name="submit" type="submit">
  	<i class="fa fa-save"></i> Simpan
  </button>
  <button class="btn btn-info btn-lg" name="reset" type="reset">
  	<i class="fa fa-times"></i> Reset
  </button>
  </div>
</div>

<?php echo form_close(); ?>

avatar Exmy31
@Exmy31

28 Kontribusi -1 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

<pre>$this-&gt;load-&gt;upload-&gt;library('upload', $config);</pre><div><br>seharusnya&nbsp;</div><pre>$this-&gt;load-&gt;library('upload', $config);</pre>

avatar Muhtasaq
@Muhtasaq

10 Kontribusi 6 Poin

Dipost 4 tahun yang lalu

Login untuk ikut Jawaban