Re: fopen - append works, write fails (but file is truncated)



On 2007-07-27, Hans Fredrik Nordhaug wrote:
I'm trying to write to a file in the current directory - no remote
files. The subject says it all - I can add that both the directory
and the file is wordwritable. This happens on a (quite good) free
hoster in Norway which doesn't use safe mode, running PHP 5.1.6 as the
PHP info below shows ...

Test it at:
http://home.no.net/moldevbk/fopen-test/?mode=w (write - fails)
http://home.no.net/moldevbk/fopen-test/?mode=a (append - ok)
http://home.no.net/moldevbk/fopen-test/p.php - PHP info
http://home.no.net/moldevbk/fopen-test/fopen-test.phps - source code of test script.

I have searched the web and usenet, but not found this problem
mentioned before. I do realize that I can work around the problem by
truncating the file first and then appending to the empty file - but
that is ugly as ...

Regards, Hans

Just some additional information:

If I delete the file I'm trying to write to, fopen with w mode creates
the file (with owner "nobody") and no errors occurs after that.
Apperently PHP is able to write to the file when it's owned by
"nobody" with permission 644, but not when it's owned by the user
"moldevbk" with permission 666. This is something I would expect to
happen if safe mode was on, but it's not. Append mode works in both
situation. The file is also truncated by the write fopen call in both
situation.

What is going?

Hans

PS! I have contacted the hoster - I'll let you know if they have
some explanation/solution to the issue.
.



Relevant Pages

  • Re: fopen - append works, write fails (but file is truncated)
    ... PHP info below shows ... ... the file (with owner "nobody") and no errors occurs after that. ... happen if safe mode was on, ... Append mode works in both ...
    (comp.lang.php)
  • Re: fopen - append works, write fails (but file is truncated)
    ... PHP info below shows ... ... happen if safe mode was on, ... I have contacted the hoster - I'll let you know if they have ... caused by incompatibilities with some of the file servers. ...
    (comp.lang.php)
  • Re: Ask Windows XP Expert Walter Clayton About Spyware
    ... retail/oem CD (not a restore set) or an I386 directory on disk. ... drive either in safe mode when AdAware and Spybot were prohibited from ... > player asking for permission to access the net through ZoneAlarm. ... Disabling SR during the weed out is dangerous. ...
    (microsoft.public.windowsxp.basics)
  • Re: Unknown Virus, Please Help
    ... permission, ... get into the registry, maybe in safe mode, and go to the following key. ... you to open the Task Manager with Ctrl+Alt+Del in normal mode, ... in a well known malware removal forum, such as SpywareInfo, GeekToGo, ...
    (alt.comp.anti-virus)
  • Re: You need permission to perform this action
    ... delete claim that I don't have permission to delete them. ... The folder I'm trying to delete is directly on the hard drive ... Go into Safe Mode and try to delete the file from there. ... arrow key to select Safe Mode. ...
    (microsoft.public.windows.vista.file_management)