467,887 Members | 1,586 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,887 developers. It's quick & easy.

flock() Permission denied error

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

// ,,
// procesing of filecontents
// ,,

if(-1==fwrite($fileHandle,$newFile)) {die($php_errormsg);}
ftruncate($fileHandle, ftell($fileHandle)) or die($php_errormsg);

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...

MacOSX 10.2

Jul 16 '05 #1
  • viewed: 1909

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by msnews.microsoft.com | last post: by
6 posts views Thread by Jon Montana | last post: by
1 post views Thread by Mark E. Hamilton | last post: by
2 posts views Thread by Taishi | last post: by
4 posts views Thread by Time Waster | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.