dongqiong8021 2015-08-20 11:33
浏览 71

在php ci框架中上传文件既不显示错误也不显示结果

I had seen many videos and took reference from CI user guide but became unable to find out error.When file is submitted from the form,it sends program flow the the uploadImage() method below.Please help me with the way. Thank you

My code:

     public function uploadImage()
    {
        $config['upload_path'] = './files/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';

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

        if(!$this->upload->do_upload())
        {
        $this->load->view('upload');
        }
        else
        {
        $this->upload->display_errors();
        }

    }
  • 写回答

2条回答 默认 最新

  • duanran8648 2015-08-20 11:44
    关注

    I don't know what are you trying to do as plz see below may help..

      public function uploadImage()
        {
            $config['upload_path'] = './files/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';
    
    //load upload class library
            $this->load->library('upload', $config);
    
    
        //$this->upload->do_upload('filename') will upload selected file to destiny folder
        if (!$this->upload->do_upload('filename'))
        {
            // case - failure
            $upload_error = array('error' => $this->upload->display_errors());
            $this->load->view('edit', $upload_error);
        }
        else
        {
            // case - success
            //callback  returns an array of data related to the uploaded file like the file name, path, size etc
    
    
        $upload_data = $this->upload->data();
    $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' .$upload_data['file_name']. '</strong> was successfully uploaded!</div>';
                 //$this->load->view('edit_profile', $data);
    
    
            redirect(base_url("Display_somepage/index"));
            }
    

    //this below may be helpful to for debugging

    echo $this->image_lib->display_errors();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题