Hello, I need to chmod a directory that is 1 level up. I tried : system("chmod -R 755 \"../directory\""); PHP: but it does not work. Any suggestions?
That would not work because PHP didn't create that folder. Just tested it and as always : Operation not permitted. When using system chmod it can chmod any folder, no matter who created it.
exam, it worked on the folder in same directory, so server allows to CHMOD. danx10, No, does not work.
Probably a restriction your host placed on you or security settings on your server because I can totally do anything with system, exec and chmod functions. It's best to ask them.
Try this: system("chmod -R 755 " . realpath('./../directory')); // or chmod(realpath('./../directory'), 755); PHP:
How about checking if the directory exists? First and foremost, you must have sufficient privileges on the directory above on which you would like to CHMOD. Something like: if(is_dir("../directory")) // Make sure we exist chmod("../directory",0755); // CHMOD should work on *nix _ONLY_ unless you're using some Widnows' emulator for it PHP: If you're looking to do a recursive CHMOD on the directory and its contents, you're going to need to use a loop. Simply opendir(); and readdir(); and chmod appropriately on all files without name "." or ".." That should work if your PHP is properly setup. Regards, Dennis M.