A
A
Alexey2015-12-06 19:18:47
PHP
Alexey, 2015-12-06 19:18:47

How to change folder permissions?

Using the function mkdir( $dir, 0777 );, I created folders on my hosting. And now I can’t delete them, rename them, change the rights, not only through filezilla, but even through DirectAdmin in the hosting control panel. The problem is that when creating, the rights to the folders were assigned not 777, but 755. And in the owner field it says "apache", and on the other folders my hosting login.
What to do in this case?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Immortal_pony, 2015-12-06
@dzheka3d

This happens if a non-zero umask is set on the server .
In order to create folders with the rights you need in this case, you can use the following code:

$old_umask = umask(0);
mkdir($dir, 0777);
umask($old_umask);

...or change permissions with chown/chmod after creation:
chown($dir, "your_user"); // Поменять владельца
chmod($dir, 0777); // Присвоить файлу другие права

Well, you can always go to the server and change the file permissions using the operating system.

S
Sergey Goryachev, 2015-12-06
@webirus

Actually, change the owner to root (most likely) or to your user in order to gain access via FTP.
Through SSH, this is done something like this:
where user is the name of the user to which you are changing the owner, and folder is the folder for which you are changing the owner.
And then you will get full rights to manage the rights of the folder.

R
romy4, 2015-12-06
@romy4

do the opposite: run rmdir in the same script

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question