[Solved] Broken File With Yii::app()->Request->Sendfile()

I’m new to Yii and I’m trying to download a file with sendfile. I have the action, and it downloads the file, but when I try to open the file it’s broken. I openend it with a binary editor (bvi) and I see 4 blank characters at the beggining, if I delete those, the file can be opened.

Any ideas of what could be the problem?

It sounds like you’re unintentionally outputting data before calling sendfile(). Make sure you have no white space before your opening <?php tag at the top of any files that are being executed. The same goes for whitespace after any closing tags. Generally it’s best to omit the closing tag completely.

What are the hexadecimal values of the characters that are being output, just out of interest?

Nice aim!!! It was that, in the main config file (config/main.php) I had 4 blank white spaces. The hexadecimal character was 20, which is the space in ascii.

Thank you very much, never would had thought it myself.