My set up: : I have a Mac running OS 10.4 set up as a server running on the network at the shop where I work. Server only accessed locally (192.168...). Sever is running php 5.2.4 and MySQL. I know just enough php and 0 unix/linux/anything about computers, so feel free to dumb it down for me!
What is happening : I am trying to write a script in php that creates a folder on the server. Later that folder would be accessed by a network user to transfer files into the folder manually. And then even later php would create a backup of the folder and its contents. I can create the folder just fine, but my problem comes down to user permissions. No matter what I try I cannot get the folder to be created through the php script and be writable by the network user. [ I go to 192.168.1.X/create-folder.php, folder gets created, perms don't allow network users write access. ]
What I've tried :
CODE
mkdir($newFolder)
This has user 'www' as owner. Group read only, Others read only.
CODE
mkdir($newFolder, 0777)
This has user 'www' as owner. Group read only, Others read only too! Got permission denied error but creates folder - seems perms set to 644 (since user creating directory isn't root?)
Logged into server directly, created a folder w/ perms of 777 in hopes that I could copy that folder and rename using
CODE
copy($file1, $file2)
And although it copied, the perms got set to 644.
Many minor variations of the above and google, google, google, google. Gettin nowhere
----------
After writing this up, I'm guessing that I need to create the folder as root user so the permissions can get set to 777. However, I was never able to get the exec function to work in php, probably because of user permissions, and in my mind even if I did get the exec fn to work I can't sudo because I would be prompted for a password, which the exec fn couldn't get passed.
I'm looking for anything that will change the permissions for me, in any sort of ass-backwards way, so long as it be automatic and immediate (by immediate I mean executed right after the folder is created. I'm
not trying to rush you into giving me advice).
I appreciate any advice or suggestions you can give!