[英]CodeIgniter captcha image not working when online
我會嘗試盡可能具體。 我使用codeigniter驗證碼助手在我的網站上生成用於驗證用戶的驗證碼,它在ly localhost上運行良好,但是當我在線上傳網站時,驗證碼沒有顯示任何內容,顯然,當我使用開發人員工具img標簽查看它時根本沒有包含驗證碼圖片的圖片。
代碼是:
$this->load->helper('captcha');
$vals = array(
'img_path' => './captcha/',
'img_url' => base_url().'captcha/',
'font_path' => './fonts/VeraSe.ttf',
);
$img = create_captcha($vals);
$x = $this->session->set_userdata('captcha', $img['word']);
$data['image'] = $img['image'];
$data['captcha1'] = $img['word'];
$this->load->view('signup', $data);
並在視圖中:
<?php echo $image; ?>
看來該腳本有一些問題,它需要額外的參數,有效的代碼是:
$vals = array(
'img_path' => './captcha/',
'img_url' => 'http://example.com/captcha/',
'font_path' => './fonts/texb.ttf',
'img_width' => '150',
'img_height' => 30,
'expiration' => 7200
);
$cap = create_captcha($vals);
$data = $cap['image'];
$this->load->view(signup, $data);
並在視圖文件中
echo $image;
重寫htaccess文件以包含captcha文件夾,例如
RewriteCond $1 !^(index\.php|asset|captcha|inc|images|robots\.txt)
有同樣的問題,但對我有用。 切記首先創建.htaccess文件的備份
對我來說,足以將目錄“驗證碼”的名稱添加到文件.htaccess中。 像寫成poly一樣:
RewriteCond $1 !^(index\.php|asset|captcha|inc|images|robots\.txt)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.