Reputation: 343
If I'm not wrong, to create or delete a file from a directory, you either need write permissions on that folder or write permission on that file (in case you're modifying it). So, in a folder with 711 permissions and a php script (in that folder) with 755 permissions, and the following code:
$fileName = "createdFile.txt";
$fileHandle = fopen($fileName, 'w') or die("can't open file");
fclose($fileHandle);
Should this create a new file or throw an error? I have tried this on the public_html folder of a webserver and it does work, which surprises me because of what I have mentioned.
Moreover, I'm kind of confused about permissions for "everyone" in the case of the webserver. If you have 777 permissions on a folder, but no php script that could actually write or move files to that folder, is there any risk at all? Or would it have to be ftp access or some php script?
Sorry for the confusing question. I'll try to clarify if I can.
Upvotes: 2
Views: 1266
Reputation: 2263
755 is read and execute not write
You would need write permissions 766 or 777
OK, a little more help. It's a safe bet that the user account that the php script is running under owns the folder and since the first digit is a '7' the 'owner' has read write and execute permissions.
Upvotes: 2
Reputation: 14149
It's hard to give a much better answer because of the limited info about the created file you're able to supply but I'm presuming that the server is running as the same user that you upload files as. This is the only explanation that I have about it being able to create a file in a directory that has 755
permissions.
I'd have a chat with your hosting provider or check their documentation to verify in case there's some kind of misconfiguration on their part.
Upvotes: 2