| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /wamp/www/sipapbd_2021_sekolah_cetak/update/application/modules/pemda/controllers/ |
Upload File : |
<?php
class Pemda extends Admin_Controller {
public function __construct()
{
parent::__construct();
$this->modul_name = 'pemda';
$this->modul_display = 'Data Pemda';
$this->view_form = 'pemda_form';
$this->load->model('pemda_model', 'data_model');
}
public function index()
{
$data = array();
$data['modul'] = $this->modul_name;
$data['modul_display'] = $this->modul_display;
$data['data'] = $this->data_model->get_data_pemda();
$data['main_content'] = $this->view_form;
$this->load->view('layout/template_admin', $data);
}
public function proses()
{
$response = (object) NULL;
$success = $this->data_model->update_data();
if($success){
$response->isSuccess = TRUE;
$response->message = 'Data berhasil diperbaharui';
$response->sql = $this->db->queries;
}
else
{
$response->isSuccess = FALSE;
$response->message = 'Data gagal diperbaharui';
$response->error = $this->data_model->last_error_message;
$response->sql = $this->db->queries;
}
echo json_encode($response);
}
public function hapus_logo()
{
$this->data_model->delete_logo();
$this->index();
}
function upload()
{
$response = (object) NULL;
$path = realpath( FCPATH.'assets/img/');
$File = realpath( FCPATH.'assets/img/logo-city.jpg');
if (file_exists($File)) {
unlink($File);
}
$config['file_name'] = 'logo-city';
$config['upload_path'] = $path;
//$config['allowed_types'] = 'gif|jpg|png|jpeg|ico';
$config['allowed_types'] = 'jpg|jpeg';
$config['max_height'] = '400';
$config['max_width'] = '400';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if(!$this->upload->do_upload('image'))
{
//return $this->upload->display_errors();
$response = array ('message' => $this->upload->display_errors(),'isSuccess' => FALSE);
}
else
{
$dataz = $this->upload->data();
//return $dataz['file_name'];
$response = array ('filename' => $dataz['file_name'],'isSuccess' => TRUE,'message' => 'Gambar berhasil diupload');
}
echo json_encode($response);
}
function icon()
{
$response = (object) NULL;
$File = realpath( FCPATH.'assets/img/logo-city.jpg');
if (file_exists($File)) {
unlink($File);
$this->data_model->update_icon();
$response->isSuccess = TRUE;
$response->message = 'Logo berhasil dihapus';
}
else{
$response->isSuccess = FALSE;
$response->message = 'Logo gagal dihapus';
}
echo json_encode($response);
}
}