Yii generated CAPTCHA image is broken

Hi, My Yii version is 1.1.4

Recently all my captcha images become invalid - they are broken some how.

I checked what’s wrong and found a UTF-8 Byte order Mark prepended in each of them.

I rechecked my files and found that I messed up /config/main.php somehow - found BOM in it.

I cleared it, but problem still persists!

I started to look through all files and found that many files are BOM’ed even in Yii framework folder. Althow they seem irrelevant to this problem, I think this should be fixed.

And I still did not find a solution to my problem. Please help.

[UPDATE] - I found BOM inside one of my php files and fixed this problem.

But, files with BOM are there mainly in ru nl and zn localization folders in Yii framework itself!

Thanks for letting us know. I’ve checked every localization file and found some with BOM. You may see here for the changes I’ve made.

What editor are you using? Usually you can setup your editor to not save any BOM.

I have the problem with captcha too.

When the page with captcha is loaded only part (one letter) of the captcha appears. I have to click ‘reload captcha’ link to see the captcha.

What can be the problem?

I’m glad being of any help to Yii development!

Actually I use Netbeans IDE for my php editing needs. But - for quick editing of config/main.php I used some windows notepad replacement :) (just once) and the rest you know…

I have had the same problem. I had to remove BOM from main.php and other files.

Thank you.

I had the same issue.

I found a BOM in my config file.


I too had the same problem. As I have used multiple editors that would be the reason for BOM addition in files. Now I have converted the files to ‘UTF-8 without BOM’ using Notepad++ And It fixed the Problem for Yii Broken Captcha Image.

If anyone want to convert all the files recursively(without BOM) then please refer this link.

Thanks! :rolleyes: