0

I'm trying to load a captcha image passing controller to view.The code of my controller

    $captcha_data['image'] = $this->captcha_security_model->get_captcha($width,$height,$characters);
//        header('Content-Type: image/jpeg');
//        imagejpeg($captcha_data['image']);
//        imagedestroy($captcha_data['image']);
    $this->load->view('captcha_view',$captcha_data);

Uncommenting that three line showing the image in full page mode.The code of my view:

<?php
echo $image;
?>
<img src="" />
<form action="" method="post">
<input type="text" name="word"  />
<input type="submit" name="submit" value="submit"  />
</form>

Loading from view is somehow failed.This code gives me this:

enter image description here

3
  • what is captcha_security_model ? you know codeigniter already has a helper for that ? maybe something is wrong with your model ! Commented Mar 21, 2013 at 17:19
  • I think captcha_security_model is ok. because uncommenting those 3 lines gives me a captcha image. Commented Mar 21, 2013 at 17:21
  • then definitely something is wrong with your model , i'm not saying it doesn't return a picture , it's just not that kind of picture that you can put inside html code . Commented Mar 21, 2013 at 17:27

1 Answer 1

1

You don't need to pass image to the view. Just out put image in 'full page mode' INSIDE CONTROLLER and in a view file put something like <img src='htttp://mysite.com/captchaimage/controller/'>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.