user8929243
user8929243

Reputation:

Php - Chmod Not Working

I want to change the chmod values of the files from the user. But it does not work. My code is;

$chmod = "0777";
chmod($filename, $chmod);

I am entering chmod 777. But the chmod value of the file is 1411. I tried chmod 0777, 777, 00777. The results remain the same.

Upvotes: 2

Views: 4577

Answers (2)

Jason K
Jason K

Reputation: 1381

The problem has to do with data conversion.

$chmod = "0777";
chmod($filename, octdec($chmod));

By just passing in the $chmod string it get converted 777 witch is not giving you want. octdec("0777") will output 511 that decimal will give chmod the value you want.

Upvotes: 6

Aniket Singh
Aniket Singh

Reputation: 877

Check the file path and file name is correct! then try this

chmod("/somedir/somefile", 0755);

Upvotes: 0

Related Questions