Forum Moderators: coopster

Message Too Old, No Replies

securimage captcha outputing strange characters instead of image

         

stephenjen

4:51 am on Aug 5, 2008 (gmt 0)

10+ Year Member



I'm trying to implement securimage. It seems to be working but the captcha image is displaying as strange string of characters: black diamond with a question mark and other strange wing-ding's.

Looks like opening an image file in a text editor. What is needed to get this to display correctly?

This is my code, which isn't much, but is supposed to be all that is needed:
require_once 'includes/securimage/securimage.php';

$image = new Securimage();

$image->show();

The last line outputs the above gibberish...

Please help. Thanks.

ag_47

5:29 am on Aug 5, 2008 (gmt 0)

10+ Year Member



You are missing headers. You basically need to tell the browser the data you are sending is not just plain text, but an image. For PNG you would use:

header( "Content-type: image/png" ); //this is before you output anything else
.
.
require( 'includes/securimage/securimage.php' ); //no need for require_once() I think
$image = new Securimage();
$image->show();

stephenjen

5:45 am on Aug 5, 2008 (gmt 0)

10+ Year Member



Hmm, that didn't do it for me. I added it right before $image->show(). Didn't get an error but still get the gibberish. Then I removed the line and added it in my index file before everything else. Still no dice.

pHp is setup to allow header to be sent even after output. Does that matter?

dreamcatcher

6:56 am on Aug 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Whats the character encoding set to for your page? Try UTF-8.

dc

ag_47

5:15 pm on Aug 5, 2008 (gmt 0)

10+ Year Member



Is your image PNG? Make sure you use the right header. (image/gif or image/jpeg)

stephenjen

6:53 pm on Aug 5, 2008 (gmt 0)

10+ Year Member



When I call the script this way:
<img src="includes/securimage/securimage_show.php"> then I get the image displayed correctly. But if I call it like this:
include ("includes/securimage/securimage_show.php") then I get the gibberish characters.

But I've created a convoluted way to get captcha to work with joomla.

Really appreciate everyone's input and fast replies.