Hello, Ive got an image upload script and im trying to make it so when i upload an image it checks if the game folder already exists, if it dosen't i want it make a folder with the game name and put the image into that folder. I had it working fine without the making the directory, but ive added this bit of code if (!file_exists("../images/games/$game_name/")) { //make the directroy mkdir("../images/games/$game_name/", 0777); } PHP: And its now making a directory but any images that go into that folder get given the wrong permissions and i lose ownership so i cannot edit the image any way. If i go into my directory admin and click "Reset Ownership" it then lets me delete/rename the image and its permission attributes. How can i get it so when the image is uploaded into the folder created by the mkdir function it gives the permissions to me so i can delete/rename it whenever i want too. Thanks in advance Olli460
You should be able to use chown to give yourself ownership of the directory and then if you need to use chmod to change the permissions. Both are available from PHP although using them would depend on how the server is setup.
Hello, Ive tried using chown but it dosen't seem to do anything. What would need changing in the server for this to work? Regards
How is PHP set up on the server? If I remember correctly, if it's an Apache module the owner is set as Apache.
Only root can run chown, and Apache is almost never running as root. So unless olli460 is running his own dedicated server or VPS, even thinking about chown is a waste of time. Check umask to make sure that it's 0, otherwise you may find that directories are not being created with the permissions you intended.
Hello, PHP Was just setup as defualt when Direct Admin was installed using CLI. I am running a dedicated server, Ive made a cron job which changes the ownership of the folders every 5 minutes, It seems to be working for now but its not an ideal solution so if anyone has anymore ideas then let me know.