开发者

Captcha image and raw format

I've trying to get properly work kcaptcha class from kcaptcha.ru in my own component. 'Cause class not build for Joomla natively I break my brain on the wall.

And at the beginning... I've a url to image generated by this class like: http://.../index.php&task=captcha&format=raw In main controller I've put method

开发者_开发知识库
function captcha() {
 include(JPATH_COMPONENT.DS.'libraries'.DS.'captcha'.DS.'kcaptcha'.DS.'kcaptcha.php');

 $session = &JSession::getInstance('default', array());
 $captcha = new KCAPTCHA();

 if ($session) {
  $session->set('captcha_keystring', $captcha->getKeyString());
 }
}

And I've see in browser

Captcha image and raw format

When I request an image from the class all working good but in my component I cannot set session variables.

Any ideas how to fix this problem?


And problem solved successfully.

For &format=raw in controller Joomla set default mime-type to text/html. For healing this issue developer must reset mime/type via setting

$document = &JFactory::getDocument();
$document->setMimeEncoding('image/png');

mime/encoding off course depends on you needs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜