PHP chmod reports success when it has not worked - why?
I have tried this:
echo substr(sprintf('开发者_高级运维%o', fileperms($mdbFilename)), -4).'<br />';
echo chmod($mdbFilename, 0777);
echo substr(sprintf('%o', fileperms($mdbFilename)), -4).'<br />';
The out put I get for the above is:
0666
1
0666
So the above has not worked! Why is this the case? And why does chmod report true?
The variable $mdbFilename
contains the path to the file which is C:\wamp\www\webs\db\access_db_1276264459.mdb
Any help will be appreciated.
Windows does not support the *NIX octal permissions.
Edit: You may also want to try clearing the stat cache before you re-read the file's permissions, ala Pekka's response.
Edit #2: Since a permission of 0777
specifies that the file is executable, why would you even want to do that to the file?
It's an MDB file, or a Microsoft Access™ database file. Why would that ever need to be executed? I think Windows determines whether something is executable by its having an executable extension (like .EXE
, .BAT
, or .COM
).
Update: I overlooked that the OP is on Windows, where there is no chmod as such. I'm leaving the answer in place because if this were on Linux, I think it would apply.
Old answer: Try adding a clearstatcache()
call between every line.
精彩评论