上传表格验证回电错误Codeigniter HMVC

时间:2016-07-15 13:54:03

标签: php codeigniter

我有功能,我想上传数据并验证其上传错误..但问题是我收到此错误Unable to access an error message corresponding to your field name Document.

公共职能登记册(){

 $this->load->library('form_validation');

$this->form_validation->set_rules('DOC_NAME',  'Document Name'    ,'trim|required');
$this->form_validation->set_rules('DOC_TYPE',  'Document Type'    ,'trim|required');
$this->form_validation->set_rules('DOC_DATE',  'Date'             ,'trim|required');

 $this->form_validation->set_rules('userfile', 'Document', 'callback_pdf_upload');

 if($this->form_validation->run($this) == TRUE){

     echo "Account Created Successfully";

 }else{
      $this->add_view();
 }



}




function pdf_upload(){

  if($_FILES['userfile']['size'] != 0){

    $upload_dir = './uploads/pdf';

    if (!is_dir($upload_dir)) {

         mkdir($upload_dir);

    }  

    $config['upload_path']   = $upload_dir;

    $config['allowed_types'] = 'pdf';

    //$config['file_name']     = 'userimage_'.substr(md5(rand()),0,7);

    //$config['overwrite']     = false;

    $config['max_size']  = '5120';



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

    if (!$this->upload->do_upload('userfile')){

        $this->form_validation->set_message('userfile', $this->upload->display_errors());

        return false;

    }  

    else{

        $this->upload_data['userfile'] =  $this->upload->data();

        return true;

}



}  

else{

    $this->form_validation->set_message('userfile', "No file selected");

    return false;

}

}

我很清楚HMVC在代码点火器上的回调问题,并且已经有了MY_Form_validation库。这有什么错误?我的错误日志中也出现错误ERROR - 2016-07-15 15:47:35 --> Could not find the language line "form_validation_pdf_upload"

1 个答案:

答案 0 :(得分:1)

更改此内容:

$this->form_validation->set_message('pdf_upload', $this->upload->display_errors());