I installed CAPTCHA module.
The image CAPTCHA works fine on my localhost...
When i upload the same module to the server, Instead of the CAPTCHA image it's displaying "image CAPTCHA" which is the alternative text in the img tag...
Text CAPTCHA and Math CAPTCHA are working well..
Having this pending for a long time.
Pls help..
thank u

Comments

Project:Drupal core» CAPTCHA
Version:6.8» 6.x-2.x-dev
Component:other» Image Captcha (image_captcha)
Assigned:Sandymaguire» Unassigned

Reassigning to the proper queue (guessing the version)

- Arie

Version:6.x-2.x-dev» 6.x-1.0-rc2
Priority:Critical» Normal
Status:Active» Postponed (maintainer needs more info)

I guess that the version is 6.x-1.0-rc2 (not 6.x-2.x)

it works on your localhost setup, but it doesn't work on your hosting server: what are the differences between the two?

i installed captcha module on the site on localhost, captcha image displays..
When i did the same on the site hosted online.The captcha image is not displaying.Instead displays text "image CAPTCHA"

#3 does not add extra information compared to the original post. Please provide more information, otherwise I can't help.

Provide version numbers (PHP, Drupal, CAPTCHA module, etc), other installed modules, hosting setup information, on which kind of forms do you enable CAPTCHAs, etc ...

Hi
PHP5
Drupal 6.9
Captcha module CAPTCHA 6.x-1.0-rc2

Other installed modules are..
abuse
CCK
Contact Forms
ddblock
email
feedapi
feedapi_mapper
flickr
image
jquery_update
link
profile_category_weight
terms_of_use
Views
webform

I have enabled image captcha in user_register ie the registration form.

what happens if you request the image URL directly (right click on the
alt text and choose something like "open image" or "view image",
depending on your browser)?

what browser are you using (firefox, opera, safari, internet explorer)?

have you tried running cron and checking if the image shows afterwards?

Hi
#6 when i right click and do view image a black scree opens up... the url is like

http://www.example.com/myproject/image_captcha/624106399

actually the module renders the

the image doesnt come instead the alternative text is coming..

#7
yes i did cron still the same prob persists..

ty

I'm having exactly the same issue with Captcha (6.x-1.0-rc2) on Drupal 6.9. I just upgraded to Drupal 6.9 from 6.8. Image CAPTCHA was working fine on Drupal 6.8. My contact form Image CAPTCHA image and the Image CAPTCHA examples produce the same behavior, i.e., the image is replaced with the allternate text "Image CAPTCHA". Also ran cron manually which had no effect on this Image CAPTCHA behavior.

ok...should have tried this first but it seems one always overlooks the obvious. I re-uploaded my font for Image CAPTCHA to /sites/all/modules/captcha/image_captcha/fonts and everything is working fine....doh!

Hi can stanb be more specific about the contents of /sites/all/modules/captcha/image_captcha/fonts .
I have nothing but a readme.txt file and it says install ttf files.
I tried putting some fonts like Grantham Bold.ttf
Still the same prob persists...
Pls help.

For ppl who get the alt text displayed instead of the captcha image.

This may sound as a rubbish solution.... But for not it worked great for me.

replace

$result['form']['captcha_image'] = array(
'#type' => 'markup',
'#value' => 'Only local images are allowed.',
'#weight' => -2,
);

on line 139 on image_captcha.module with the following

$result['form']['captcha_image'] = array(
'#type' => 'markup',
'#value' => 'Only local images are allowed.',
'#weight' => -2,
);

1.U are setting the alternative text alt= "'.t('image CAPTCHA') with alt="'. t($code).
2.Strike through the text.
3.Also display a background image behind the code.

@Sandymaguire: After putting the ttf file into the font directory, you should select it in the image captcha settings. Otherwise the font won't be used.

I have exactly the same issue, since 6.9 Captcha's images are broken.

After several investigations, it appears that drupal, since 6.9 (and still in 6.10) adds 3 headers lines to any page, including the jpeg image of Captcha, so corruping the jpeq response content ...

A work-arround, is to empty the response buffer in the hook_init of mymodule (or any module you could change), as follow:

<<
function mymodule_init() {

// CAPTCHA FIX: empty output buffer for captcha image generation.
if (substr($_GET['q'],0,14) == 'image_captcha/') ob_clean();
}
>>

May i suggest to include a call to ob_clean() in the function image_captcha_image($seed=NULL) ?

On the drupal side, who knows which mymodule's code could be call before mymodule_init() ?

at #14: I can't reproduce your findings on my Drupal 6.10 setup, so I don't think those three header lines are from Drupal core.
I assume the problem lies in one of the contrib modules you installed.
can you check this?

Ooups ! I finaly find : some of include files of my module have the ?> tag plus an empty line at the end. That's the way empty lines came into the page before the call to mymodule_init() ! The empty line was copied to the output ...

I saw that Drupal's code have not end tag at all and that many people accept it as a good practice ... That's just a problem if you use a XMLEditor.

I saw that Drupal's code have not end tag at all and that many people accept it as a good practice

Indeed. For those interested: in PHP the closing ?> is optional and not using it is recommended/best practice in Drupal code.

(Edit: better wording of what I wanted to say)

I ran into this same problem using Drupal 6.10 and image captcha 6.x-2.0-beta3. After reading this page I went back and checked my custom modules, sure enough I'd left a closing ?> followed by blank lines at the bottom of one of my (unrelated) modules and after removing that the image captcha image came back.

true,
solved here also, maybe more than one empty line at the end could lead to this, even if closing ?> does not exist

I spend a fair amount of time chasing this bug in one of my sites. My problem was originally not getting the image captcha, then when I switched to math captcha for testing I was getting a captcha token invalid message.

I had deleted user 0 during a cleanup of users from extensive testing for code that automatically creates new users. I deleted all but admin (user 1). Restoring user 0 solved my problem. The weird thing is that all non auth users were getting sessions, but never seemed to get captcha data in those sessions.

Found the answer in another thread related to the invalid token, but wanted to pass it on. This solved my problem without any code modifications.

Drupal 6.12
Captcha 6.x-1.0-rc2

All browsers.

Hi everyone,

I have same problem (it works great into a WAMP framework, but it doesn't run into a Linux environment), without inconsistency in user table.

So, are there other causes for non-working image captcha?

Drupal 6.13
6.x-2.0-rc2

So, are there other causes for non-working image captcha?

this thread discusses several other causes too: see #6, #14-#17

@#6:
with IE (clicking on broken image link --> view link/open page http:///image_captcha/82/1247476990): the web page cannot be rendered.
with Firefox (clicking on alt text --> view link/open page): blank page.

@#14 & @#17:
I have no custom module. How (and where) should I apply that solutions? How can you be confident that different php code (closing tag and/or a patch) can solve this issue in a Linux environment, whereas in a WAMP env. all is working great?

@Alex72RM: what do you get when you download the image url with "wget" under linux/osx?
Or if you are not familiar with wget and the site is publicly accessible: send me the link through my contact form

@Alex72RM: I got your message and tried the link, but the request for the image returns nothing

$ wget http://example.com/image_captcha/89/12474
--12:11:10--  http://example.com/image_captcha/89/12474
           => `12474'
Resolving [snip]
Connecting to [snip] ... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

so it's not the problem of #14-#17

Another possible reason is that your linux PHP setup has no support for the imagejpeg function. Did you build the site on one setup (with imagejpeg support) and then moved it to that linux setup (possibly without imagejpeg support)? For more info see #205525: Images cannot be generated, because your PHP installation's GD library has no JPEG support. you can also get more information about your setup at example.com/admin/logs/status/php (there should be something like "--with-gd", GD is the PHP image handling library)

Hi again,

phpinfo() tell me that gd is all ok.

Freetype support: enabled
Freetype linkage: with freetype
JPG Support: enabled

Getting same problem ....

Please provide more info than "getting the same problem". If that's all you give me, I can't help you.

e.g.:
which version of drupal, captcha module?
what's your webserver setup (linux? php version?)
does the image work on the image CAPTCHA admin page? does it work for authenticated users?
are there related error messages in the drupal log, webserver log or php log?
do you have a uid=0 in your users table? (which is common source for problems in CAPTCHA 5.x-3.x and 6.x-1.x, see http://drupal.org/project/issues/search/captcha?issue_tags=captchauid0)

Hi again,

I hope my response could be useful.

which version of drupal, captcha module?
6.13, 6.x-2.0-rc2

what's your webserver setup (linux? php version?)
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7| DAV/2 PHP/5.2.6 Phusion_Passenger/2.0.5

does the image work on the image CAPTCHA admin page? does it work for authenticated users?
It doesn't work at all, for authenticated users (from examples pages into captcha admin section, the behavior is the same) nor anonymous ones.

are there related error messages in the drupal log, webserver log or php log?
No errors in drupal log (it's written that image_captcha.js has been processed). I cannot investigate further into webserver/php log...

do you have a uid=0 in your users table? (which is common source for problems in CAPTCHA 5.x-3.x and 6.x-1.x, see http://drupal.org/project/issues/search/captcha?issue_tags=captchauid0)
Yes, uid 0 is there.

Subscribing

I have Two sites running with almost same modules installed but image captcha is working fine with one (image is displaying) but not with other.

What might be the reason ,I am not having any possible reason to explain my client (no version compatibility excuses) because it is running with one perfectly.

Plz help, very urgent !!!!!!!!!!

at vijayitsoft: does CAPTCHA 6.x-2.x work? does the simple math challenge work on both sites?
your problem is probably cookies: are the cookie domains correct for both sites?

it can be fuzzy but now works, latest actions:

clear all caches
http://pshahmumbai.wordpress.com/2009/08/09/clear-drupal-caches/

make and run from root a php file using this code

<?php
  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  drupal_flush_all_caches();

install latest captcha-6.x-2.0-rc3 but remove the additional space at the end of captcha.inc file
try that in other modules too if you still cannot get the images...
if this is the issue, someone could write a global core patch or a module to check those (*.module, *.inc) files for spaces and prevent this bug in general...

Version:6.x-1.0-rc2» 6.x-2.0-rc3

I am experiencing the same problem and none of solutions above worked for me.

I have uid=0 in users table, I switched page compression off, flushed cache, and still no progress.

Math captcha works, but there is no captcha image for anonymous users. Strange thing, on administration page I have a perfectly looking image captcha example.

Please, let me know which informations are needed to solve this problem?

Thanks a lot

at jennalexx in #33: why do you suggest to remove additional space at the end of captcha.inc and other files? What would this be good for? One thing that can break image captcha is a closing ?> delimiter followed by whitespace at the end of a module or include file. But captcha.inc does not have a closing ?> delimiter, as most drupal module and include files, so there is no problem here.

at timurek in #34: when you say math captcha works, does this just mean that it shows a challenge, or does it mean that it also correctly blocks wrong answers and accepts right answers? Other interesting info: look at the markup code and report how an captcha image url looks like, try to load a captcha image url directly and report what you get (nothing, error message, an unreadable file, ...) also try different browsers for this.

#35: Match CAPTCHA shows challenge, but also blocks when wrong answer is entered. I use it as well as other types of captchas from captcha pack :)
Image captcha: As anonymous user, when I try to access image captcha file directly, i got nothing:
http://www.vypocetni.technika.cz/image_captcha/%252F1252081547
But (working) image in administration module has another type of URL:
http://www.vypocetni.technika.cz/image_captcha/784/1252081520
Is it not strange? Especially the %252F part?

Issue appears in any browser I tried - IE, Opera, Firefox.

Thanks for taking care of it.

At #36: see #431672: Image does not show in image_captcha when using random_captcha_type, the problem is in CAPTCHA pack, you should update to a version after 19 august, like 6.x-1.x-dev or 6.x-1.0-beta3

Works, thanks a lot!

I was having a very similar problem. I had the latest official release of CAPTCHA installed (6.x-2.0) in sites/all/modules of a multi-site installation. And Image CAPTCHA was working fine on every site but one. I tried every solution above, with no luck. So I downloaded the 6.x-2.0-dev version, thinking it was worth a try. I opened up the install file just to see if it was going to require a database update, and that prompted me to check the schema version for CAPTCHA in the systems table of the recalcitrant site. Ah hah. Turns out that, while I had the latest official release installed on that site, I hadn't run the updates on that site (as I had on all the others). I ran the updates, and bingo, it worked.

I did end up installing the dev version of the module as a result of the update (I had put it in sites/recalcitrant.site/modules/captcha_2, but apparently Drupal looks at the info file not the folder name). However, I am pretty sure that it was the database update and not the new code that fixed it, since that had been the ONLY difference between this site and the other sites that were functioning properly.

I had exactly this issue. Image Captcha worked perfectly under MAMP localhost but broke on my production server. I fixed it by installing the GD image library and restarting the server. Instructions here:
http://www.cyberciti.biz/faq/ubuntu-linux-install-or-add-php-gd-support-...

I have godaddy account and had this problem as well.
- Server: linux, php 5.2.8
- Drupal: 6.16
- Captcha : 2.1 (latest)
- Freetype support: enabled
- Freetype linkage: with freetype
- Image didn't work on admin page, no preview images for available fonts, examples also didn't work
- Math captcha works (block wrong answers, accept correct answers)
- No other contributed modules installed
- No errors in log file

Have the same problem. On one site with the hoster it works, same hoster other account it does not work. Cannot find any differences between the accounts.

Version:6.x-2.0-rc3» 6.x-2.x-dev
Assigned:Unassigned» mimohodom
Status:Postponed (maintainer needs more info)» Active

Hi,

I've got the same problem and I am dead stuck. The math_captcha works nice, but once I switch to images there is nothing but alt text.
I could not even manage images on admin page, and there was no preview for available fonts, examples as mentioned in #41

Software configuration is as follows:

Server: Windows 2003
Web server: WAMP 2.0 (Apache 2.2.11, php 5.3.0, mysql 5.1.36)
Drupal: 6.16
Captcha : tried 2.x-dev, 2.1, 2.0-rc3
Browsers: Chrome, FF 3.6.8, IE6, IE8

I played a little bit with the module and made it to display (embedded) images - data-uri, base64 - by ($captcha_sid - 1).
Unfortunately, this functionality is not supported in IE6 (pardon me) which is a must for me ...

There is one thing to notice about this obviously wrong idea. I had to update captcha_sessions table with the $code value so to say "by hand" to implement it. And image renewal didn't follow a page refresh. But this ($captcha_sid - 1) emerged from the fact that I was constantly getting a captcha image `UNDEFINED' -- which was a rendering of the db_query result with $captcha_sid as a parameter.

at mimohodom in #43: have you already tried/checked for the stuff discussed in #6, #14-#17, #25 ?

Also, if it's on a public site, providing a link to it can help debugging the problem (if you don't want to disclose it publicly here in this thread, use my contact form)

Hi mimohodom,
I received your message with the link.

The CAPTCHA images do not show up because they are corrupt.
There are an extra 12 bytes before the PNG data for some reason.

E.g. This is a dump of the first bytes of your corrupted CAPTCHA image:

0000000 357 273 277 357 273 277 357 273 277 357 273 277 211   P   N   G
0000020  \r  \n 032  \n  \0  \0  \0  \r   I   H   D   R  \0  \0  \0 330
0000040  \0  \0  \0   H  \b 002  \0  \0  \0 033   $ 254 371  \0  \0  \0

A normal PNG looks like this

0000000 211   P   N   G  \r  \n 032  \n  \0  \0  \0  \r   I   H   D   R
0000020  \0  \0  \0 200  \0  \0  \0   F  \b 006  \0  \0  \0 004 217 234
0000040   b  \0  \0  \0 004   g   A   M   A  \0  \0 257 310   7 005 212

The usual cause of this is discussed in #14-#17 and #271883: no CAPTCHA image because of corrupted images: when a modules on your site uses a closing ?>-tag with trailing whitespace, you get this whitespace before the stuff Drupal outputs, the image data in this case.
However, the strange thing is that the prefixing bytes in your case (357 273 277 357 273 277 357 273 277 357 273 277 or in hexidecimal: bbef efbf bfbb bbef efbf bfbb) do not seem related to whitespace.
Also note that you have these bytes at the start of your html pages too (careful: the "view source" tool of your browser may hide these, so use some sort of more advanced editor or hexdump tool to see this).

Anyway: the problem is not in the CAPTCHA module,
maybe some other module on your site generates these erroneous bytes or there is a problem with your setup. You could try disabling some modules and see what happens for example.

Status:Active» Fixed

Hi saxofaan,

thanks (again) for your support. The problem turned out to be with my own modules: all the .info, .module and .inc files were encoded in UTF-8. Converting them to ANSI solved the issue.

Hope, this note will save somebody's time.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

i am using d6, on my site some time captcha image become invisible. although i didn't worked on this module. as i am working on numbers of custom module. so if there is any mistake in code i do. the captcha image become invisible. so it is difficult to find issue.
can any one tell how this can be resolved.
i am also wonder why this is effected by working on other custom module.

Version:6.x-2.x-dev» 7.x-1.0
Issue summary:View changes
Status:Closed (fixed)» Active

I'm encountering a problem which was discussed there some time ago, with Drupal 6. But now it occurs with Drupal 7.

I have two Drupal 7 websites. The first one, http://sunsethill.ubud/ is almost finished and used math captcha. The second one, http://thewoolenbarn.com/ is only a skeleton with empty pages. I used math captcha on the first website, and begun using image captcha on the second one. Since it seems to be much safer than math captcha, I changed to image captcha on the first website. But the image does not appear: I see a pseudo-image when using Chrome, and the contents of the alt=field when using Firefox.

I read the full discussion here, and made several attempts. For example, I uninstalled the captcha module and then installed it again. At the moment, image captcha is used only on the register page http://sunsethill-ubud.com/user/register

The src= field of the img tag mentions the directory image_captcha which does exist on the website. When comparing the html code of the two sites, I cannot see any significant difference. The two websites use very similar modules, including Commerce, but the website where image captcha does not work also uses the Rooms module.