Gregwar / Captcha

PHP Captcha library
MIT License
1.71k stars 286 forks source link

What am i doing wrong? #70

Open Pappu420 opened 5 years ago

Pappu420 commented 5 years ago

I installed via composer

<?php include_once($my_dir . "/captcha/vendor/autoload.php"); use Gregwar\Captcha\CaptchaBuilder;

$builder = new CaptchaBuilder; $builder->build(); header('Content-type: image/jpeg'); $builder->output();

On IE , in the console, i see DOM7009: Unable to decode image at URL: '<>' with MIME: 'image/jpeg'.

In firefox, in the main browser window, i see "the image <<>> cannot be displayed as it contains errors

If i remove the header line, i do see a lot of junk chars and a jpeg header being sent out. So it does look like i have the relevant libraries for PHP installed

$my_dir is outside my web directory, but i don't think that should matter, right?

Thanks in advance for any help!!!!

Pappu420 commented 5 years ago

I got it!

One of the included files was returning an extra space and screwing up the headers and output.

In such a case, the native PHP error is expected... something like headers already sent or something :-(

Please include it to avoid headaches for other unsuspecting newbies like me :-)

Gregwar commented 5 years ago

Unfortunately this is hard to provide a better error message there since this is more a PHP issue, that is even more likely to happen if you use closing tag ?> with extra space after