小编kam*_*gfx的帖子

CodeIgniter - 如何显示来自do_upload的错误消息

我想在重定向链接上显示内容插入的成功消息.这是我的控制器代码: -

public function do_upload($field) {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100000';
        $config['max_width'] = '3000';
        $config['max_height'] = '3000';

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

        if (!$this->upload->do_upload($field)) {
            $error = array('error' => $this->upload->display_errors());

            return $error;
        } else {

            $updata =$this->upload->data();
            $data = $updata['raw_name'].$updata['file_ext'];
            return $data;
        }


     }


public function index() {

 $this->load->model('blog');

        if(isset($_POST['post']) && (!empty($_POST['post']) || strlen($_FILES['inputUpProfile']['name']) > 0) ){
        if(strlen($_FILES['inputUpProfile']['name']) > 0) 
        {
        $pic = $this->do_upload('inputUpProfile');
        print_r($pic);
        if ($this->input->post('post') == ''){$type="image";} else {$type="image-with-text";}
        }

        else {$pic = ""; $type = "text"; …
Run Code Online (Sandbox Code Playgroud)

php codeigniter

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

codeigniter ×1

php ×1