Page 1 of 1

File download and spurious CR

Posted: Sat Mar 05, 2005 7:33 am
by mbrampton
It was a struggle to debug this, and all sorts of other things seemed more likely than the final explanation. Such is the way!

I support Remository, a file repository for the Mambo CMS. The download mechanism has been changed by me, and relies on sending headers followed by the file, simple transferred using readfile().

When the PHP routine just dropped off the end, this apparently resulted in IE and Firefox receiving files with a stray CR character on the end. Opera (my preferred browser) did not. The CR did no harm for most purposes, but upset PCLZIP, which is used for component installation in Mambo. There, the CR caused a fatal error (with unhelpful diagnostic).

The solution is to code an exit statement at the end of the PHP. That solves the problem, but I am left asking if anyone knows why it does?

Posted: Sat Mar 05, 2005 8:34 am
by feyd
if you have any stray blank lines or echo statements, this will add to the binary stream

Posted: Sat Mar 05, 2005 8:42 am
by mbrampton
No executable statements at all (although a function definition). But there might well have been an odd line after the ?>. That would have been sent then? As a CR?

Posted: Sat Mar 05, 2005 8:43 am
by feyd
yep.

Posted: Sat Mar 05, 2005 8:48 am
by mbrampton
Thanks. It's nice to understand what has happened, not just get a fix!