2016-07-15 12 views
-1

i Funktion haben, wo ich Daten hochladen möchten, und haben ihre Upload-Fehler validiert .. aber das Problem ist, ich Unable to access an error message corresponding to your field name Document. diesen Fehler bekamHochladen von Formularvalidierung Rückruf Fehler Codeigniter HMVC

public function register() {

$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; 

} 

} 

Ich bin mir der Rückrufprobleme von HMVC auf Code-Zünder bewusst und habe bereits die MY_Form_validation-Bibliothek. Was ist der Fehler davon? Ich habe auch den Fehler ERROR - 2016-07-15 15:47:35 --> Could not find the language line "form_validation_pdf_upload" auf meine Fehlerprotokolle.

Antwort

1

ändern diese:

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

Sie sollten Datei zum Hochladen Upload-Bibliothek verwenden – pradeep

Verwandte Themen