回调代码点火器无法访问



我有一个控制器

function append_bukti()
{
$this->load->library('form_validation');
$this->load->helper('file');
$this->form_validation->set_rules('nomor_nota', 'Nomor Nota', 'trim|required');
$this->form_validation->set_rules('jumlah_tagihan', 'Jumlah Tagihan', 'trim|required');
$this->form_validation->set_rules('date_payment', 'Tanggal Pembayaran', 'trim|required');
$this->form_validation->set_rules('file', '', 'callback__file_check');
if ($this->form_validation->run()){
$er="bener";
echo json_encode($er);
}else{
$array = array(
'error'                 => true,
'nomor_nota_error'      => form_error('nomor_nota'),
'jumlah_tagihan_error'  => form_error('jumlah_tagihan'),
'date_payment_error'    => form_error('date_payment'),
'file_error'            => form_error('file'),
'validasi'              => $this->form_validation->run()
);
}   
echo json_encode($array);
}

这是函数回调

public function _file_check($str){
$allowed_mime_type_arr  = array('image/png','image/x-png');
$mime                   = get_mime_by_extension($_FILES['file']['name']);
if(isset($_FILES['file']['name']) && $_FILES['file']['name']!=""){
if(in_array($mime, $allowed_mime_type_arr)){
return true;
}else{
$this->form_validation->set_message('file_check', 'Silahkan pilih hanya file pdf/gif/jpg/png.');
return false;
}
}else{
$this->form_validation->set_message('file_check', 'Silakan pilih file untuk diupload.');
return false;
}
}

如果我运行这个函数,就无法处理并且什么都没有。如果所有表单都是true,那么我为什么要echo$this->validation->run((仍然是echofalse。我需要你的帮助。欢呼

'validasi'  => $this->form_validation->run()

这一行使函数递归,并且它永远不会结束。只需将其设置为false

'validasi'  => false
);
echo json_encode($array); //put this statement into the else scope
}   
}

相关内容

  • 没有找到相关文章

最新更新