Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chmod 777 in php

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?

like image 509
Yens Avatar asked Aug 24 '26 17:08

Yens


1 Answers

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

like image 66
RobertPitt Avatar answered Aug 26 '26 06:08

RobertPitt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!