U
U
Uzair Izha2018-12-21 10:16:10
linux
Uzair Izha, 2018-12-21 10:16:10

How can I change the permissions of a folder and its attachment using php?

I have a temp folder with files. I need to change the permissions of the contents of the temp folder. It's important to know that the content of the temp folder is an unpacked zip and I don't know exactly what files are in there.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Lyskov, 2018-12-21
@UZEIR

exec ("find /path/to/folder -type f -exec chmod 0777 {} +");  - папки
exec ("find /path/to/folder -type d -exec chmod 0777 {} +"); - файлы

D
Dmitry Shitskov, 2018-12-21
@Zarom

Recursively change permissions on all files in a directory:
php.net/manual/en/function.chmod.php#87826

<?php

$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pathname));

foreach($iterator as $item) {
    chmod($item, $filemode);
}

?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question