tags:

views:

19

answers:

2

Hello all,

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.

+3  A: 
amphetamachine
Ah, this is on Windows. That's the solution then. +1
Pekka
I think it does work - It seemed to have worked for this commentor on php.net: http://www.php.net/manual/en/function.chmod.php#72419 ??
Abs
@Abs: `0777` is read (`4`) + write (`2`) + execute (`1`) for user, group, and others. The Windows version is probably configured to return `0444` for read-only files and `0666` for read/write files.
R. Bemrose
Actually, it seems more people say that it doesn't work and once person says it works in the comments. I'll have to come up with something else. Thanks.
Abs
@R. Bemrose: Most of the time Windows also allows execution of any file, so it would be `0777` for read-write and `0555` for read-only.
amphetamachine
+2  A: 

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.

Pekka
+1 Yep. I've had problems with that damn stat cache before.
amphetamachine