1
如何獲取Codeigniter驗證碼圖像庫。配置erquired定義'img_path' => '', 'img_url' => '',
,但我沒有這樣的文件夾或圖像,我紅洙很多教程和笨文檔以及..但沒有一個描述如該驗證碼庫位於..如何獲取Codeigniter驗證碼圖像庫
功能
public function captcha() {
/* Set a few basic form validation rules */
$this->form_validation->set_rules('name', "Name", 'required');
$this->form_validation->set_rules('captcha', "Captcha", 'required');
/* Get the user's entered captcha value from the form */
$userCaptcha = set_value('core/captcha');
/* Get the actual captcha value that we stored in the session (see below) */
$word = $this->session->userdata('captchaWord');
/* Check if form (and captcha) passed validation */
if ($this->form_validation->run() == TRUE &&
strcmp(strtoupper($userCaptcha), strtoupper($word)) == 0) {
/** Validation was successful; show the Success view * */
/* Clear the session variable */
$this->session->unset_userdata('captchaWord');
/* Get the user's name from the form */
$name = set_value('name');
/* Pass in the user input to the success view for display */
$data = array('name' => $name);
$this->load->view('pages/captcha-success-view', $data);
} else {
/** Validation was not successful - Generate a captcha * */
/* Setup vals to pass into the create_captcha function */
$vals = array(
'word' => 'Random word',
'img_path' => '',
'img_url' => '',
'img_width' => '150',
'img_height' => 30,
'expiration' => 7200
);
print_r($vals);
/* Generate the captcha */
$captcha = create_captcha($vals);
$data['captcha'] = $captcha;
$data['image'] = $captcha['image'];
/* Store the captcha value (or 'word') in a session to retrieve later */
$this->session->set_userdata('captchaWord', $captcha['word']);
/* Load the captcha view containing the form (located under the 'views' folder) */
$this->load->view('pages/captcha-view', $data);
}
}
具有負載驗證碼助手或什麼錯誤你長了? –
它只是驗證碼助手...沒有圖像文件夾? – KBK
你不得不在這裏提到你的文件夾路徑'img_path'=>'', –