Hello,
when using flock() I get a permission denied error:
Warning: fopen("<filename>", "r+") - Permission denied in <pathtofile>
on line 7
I do this:
$fileToOpen=substr($PHP_SELF, strrpos($PHP_SELF,"/")+1);
$fileHandle=fopen($fileToOpen, 'r+') or die($php_erormsg);
flock($fileHandle,LOCK_EX | LOCK_NB);
$fileString=fread($fileHandle, filesize($fileToOpen)) or
die($php_erormsg);
// ,,
// procesing of filecontents
// ,,
rewind($fileHandle);
if(-1==fwrite($fileHandle,$newFile)) {die($php_errormsg);}
ftruncate($fileHandle, ftell($fileHandle)) or die($php_errormsg);
flock($fileHandle,LOCK_UN);
fclose($fileHandle);
It seems to me that I incorrectly place the flock()'s but the manual
suggest putting flock($fileHandle,LOCK_EX) after the fopen() and the
flock($fileHandle,LOCK_UN) before the fclose()...
Placing the flock($filehandle, LOCK_UN) just before the fclose()
produces the same result...
All I can do from that point on is to delete the file and use a new
(copy of the unaffected) file...
php4.1.2
MacOSX 10.2
Marc