0

I am trying to give 777 permissions to a folder on my hosting. I use the following command: chmod("./test",0777);

I know it doesn't work because I execute a script which changes a file in the directory.
If I give the permissions manually (in the FTP) it works. Why doesn't the chmod work?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Ron
  • 3,975
  • 17
  • 80
  • 130
  • Is the script in the same directory as `test`? – brbcoding Apr 03 '13 at 18:28
  • 7
    when running this from php, the user is usually 'apache'. This user doesn't have access to do many things, for security reasons. – Aris Apr 03 '13 at 18:31
  • nope, should be in the same directory? Aris, I can chmod files but not folder? different security rule for folders and files? – Ron Apr 03 '13 at 18:32
  • Have you tried without the `./` and just `chmod("test",0777);` and where are you executing from? – Funk Forty Niner Apr 03 '13 at 18:33
  • @Ron Aris got it right, it's a permission problem of the user running the command – scones Apr 03 '13 at 18:34
  • to be honest I used `../test` because the folder is one step above... just wrote it this way so it will be easier – Ron Apr 03 '13 at 18:34
  • [related](http://stackoverflow.com/questions/9432990/how-to-chmod-the-folder-to-make-it-writable-for-the-server-in-php) post... also [here](http://stackoverflow.com/questions/5019194/chmod-777-in-php). – Lix Apr 03 '13 at 18:35
  • can I let the php use different user or something similar? – Ron Apr 03 '13 at 18:37
  • have you tried different combinations, such as `chmod("/test",0777);` and my other suggestion? – Funk Forty Niner Apr 03 '13 at 18:37

0 Answers0