我正在创建上传,编辑和删除在Codeigniter,我希望引导警报应该显示上传错误(如果有的话)在div警报。代码的控制器如下所述,请协助。
控制器代码从此处开始
<?php
defined('BASEPATH') OR exit ('No direct script access allowed');
/**
*
*/
class Admin_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->library("session");
}
public function registerAdminDetails()
{
$config['upload_path'] = 'assets/img/uploads/reg_Admin/';
$config['allowed_types'] = 'jpg|jpeg|png';
$config['max_size'] = '2048';
$this->load->library('upload', $config);
if(! $this->upload->do_upload('avatar'))
{
$error = array('error' => $this->upload->display_errors());
$this->session->set_flashdata('error', $error);
$this->load->view('admin_access/admin_add_new');
}
else
{
$avatar_upload = $this->upload->data();
$data = array(
'admin_name' => $this->input->post('admin_name'),
'admin_username' => $this->input->post('admin_username'),
'admin_email' => $this->input->post('admin_email'),
'admin_password' => $this->input->post('password'),
'admin_profile_pic' => $this->input->post('avatar'),
'admin_profile_pic' => $config['upload_path'].$avatar_upload['file_name']);
$this->db->insert('admin_profile',$data);
echo "<script>alert('New Admin Successfully Enrolled')</script>";
$this->load->view('admin_access/profile/admin_add_new');
}
}
}
?>
2条答案
按热度按时间dluptydi1#
qgelzfjb2#
控制器:
我的示例视图(是的,我正在使用引导程序):