If I create a folder in php with mkdir() it has the www-data : www-data user and 755 permissions.
The problem is I can't delete this folder with the ftp-user (zapbe:psasrv)
I tried to modify the folder with chmod($path, "0777") in php but this doesn't work.
How can I make the created folders and uploaded files readable / removeable for both the www-data and the ftp-user?
bool chmod ( string $filename , int $mode )
Within PHP they might be some limitations on the security, therefore the depending on your configuration it may not work.
The above function returns a booleon to let you know either it has succeed in changing the entities permissions.
if(!chmod($directory,0777))
{
echo "Unable to chmod $direcotry";
}
Also a quote from PHP:
The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems.
Understanding above you should look at chown
In order to remove a directory, you need to have write permissions on the parent directory, not on the one you want to remove. In order to provide write access on the parent, a good approach would be to make that parent owned by some group that both www-data and your ftp user are members of, and never use the 777 permissioning. Also, make sure your parent folder does not have the sticky bit set.
by default when you create a folder in *nix other users will not have the ability to delete/modify the folder.
to change the permissions of the www-data created folder, run the command in a php script from the browser and it should update successfully
Note don't put the new permissions in double quotes, it needs to be an
octal number
chmod($path, 0777);
// not chmod($path, "0777);
Once you do that anyone can modify the folder
Remove the double quote and try and also check for the owner of file
chmod($path, 0777)