I have a controller that is generating a captcha and all works fine. There is an issue however using the redirect()->back() which seems to redirect to the last image generated on screen via another controller embedded within the <img> HTML tag.
The captcha is shown on screen fine and is generated through the view as per the code below:-
Code:
<div class="text-center m-0">
<img src="<?php echo base_url('captcha/8/330000/ffffff/1'); ?>" id="captcha" class="captcha" alt="Captcha loading..." />
</div>
The captcha is produced via a controller that extends the BaseController and contains the code below that generates and outputs the captcha in the <img> tag:-
Code:
imagefilledrectangle($image,0,0,200,150,$backgrd);
imagettftext($image, 30, $angle, 10, 90, $color, $font, $code['rand_code']);
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
All works perfectly but when I use the redirect()->back() (which I would like to use with withInput(); to retain the form data), the redirect goes to http:{mywebsite}/captcha/8/330000/ffffff/1 which is then displaying the PNG file as a series of uncoded characters. I was using redirect()->to({URI}) before which worked fine but this doesn't retain any of the form data that's passed.
I think I understand why the redirect()->back() is accessing the controller that generated the PNG file as it's the last controller accessed, so does anyone have any ideas on how I could get around this and eliminate that controller from the redirect?
Thanks in advance.