2013-05-04 48 views
0

我在根目錄下的WAMP上安裝了CodeIgniter。問題出現在這裏:我一直在嘗試驗證碼。我的captcha文件夾是C:\wamp\www\captcha。問題是,當產生新的驗證碼CodeIgniter - captcha文件夾中的.htaccess文件被刪除

的.htacces文件的內容是驗證碼內的.htaccess文件被刪除:

RewriteEngine on 
RewriteRule !.*\.jpg - [F,L] 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule (.*) - [F] 

我用它返回一個Forbidden .....消息,如果.. .. .jpg文件存在。

目前我只在/ view文件中有這個。我還沒有實施任何檢查/提交方法。我覺得我需要先解決這個問題。

$this->load->helper('captcha'); 
$vals = array(
    'img_path' => './captcha/', 
    'img_url' => 'http://localhost/captcha/', 
    'img_width' => '150', 
    'img_height' => 30, 
    'expiration' => 25 
    ); 

$cap = create_captcha($vals); 
echo $cap['image']; 

在此先感謝。

回答

0

答案很簡單acctually:只需創建一個文件夾內captcha(在我的情況images),並相應修改文件:

的.htaccess(在captcha文件夾)

RewriteEngine on 
RewriteRule ^([0-9]+)\.([0-9]+)\.jpg$ ./images/$1\.$2.jpg [L] 

RewriteRule !.*\.jpg - [F,L] 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule (.*) - [F,L] 

其他「查看」文件

$this->load->helper('captcha'); 
$vals = array(
    'img_path' => './captcha/images/', 
    'img_url' => './captcha/', 
    'img_width' => '150', 
    'img_height' => 30, 
    'expiration' => 3600 
    ); 

$cap = create_captcha($vals); 
echo $cap['image'];