NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP 4.3RC2 Module and Apache 2.0 revisited

Hans Zaunere hans at nyphp.org
Sun Dec 1 23:14:09 EST 2002


--- evan heller <evan.heller at alum.rpi.edu> wrote:
> Hi:
> 
> Does anyone know why apache would corrupt files
> over a few K. I am running Apache 2.0 with php as
> a module and with virtual hosts. The upload
> directory is set correctly and I'm running with
> the open_basedir and safemode on.

As noted in other posts, be sure to run Apache 2 in it's classic prefork
process model (http://httpd.apache.org/docs-2.0/mod/#core).  I've had issues
with threads on FreeBSD, but seems to work well on RH 7.3; no idea what the
process model under Windows (mpm_winnt) means, however.  Either way, AFAIK
PHP isn't thread-safe yet, so go with the prefork process module.

> Any thoughts or ideas why images would be
> corrupted. For example, I have the system output
> bad data and it says that a file sized: 63,887
> bytes gets uploaded as 113,231 bytes?? Anyhow, I'm
> confused why this would happen. Any help would be
> of great assistance.

Although the size increase seems a bit large, this sounds like it could be a
binary safety issue.  UNIX doesn't make a distinction for most file
operations but Windows will.  Make sure you open the file properly, something
like: fopen('pathtofile', 'rb') (the b is vital, as noted in the second Note
at http://www.php.net/manual/en/function.fopen.php

And make sure that the other functions you are using within PHP to operate on
the file's data are specified as binary safe (not fgets(), but rather
fread(), for example) and the Note at
http://www.php.net/manual/en/function.fread.php

Best,


=====
Hans Zaunere
New York PHP
http://nyphp.org
hans at nyphp.org



More information about the talk mailing list