Ok,
so if 2 people say that my way is wrong and the other is right, i will take mine back.
I posted it cause for me just the way i used it worked (i don't know why)
AND: i would not say something like: "I would try before post", in my opinion that is realy unfriendly, cause i tryed!
ftp_chmod
(PHP 5)
ftp_chmod — Устанавливает права доступа к файлу
Описание
int ftp_chmod
( resource $ftp_stream
, int $mode
, string $filename
)
Устанавливает права доступа к указанному удалённому файлу в значение mode .
Список параметров
- ftp_stream
-
Идентификатор соединения с FTP сервером
- mode
-
Новые права доступа, указанные в виде восьмиричного значения.
- filename
-
Удалённый файл.
Возвращаемые значения
Возвращает новые права доступа к файлу в случае успеха или FALSE в случае ошибки.
Примеры
Пример #1 Пример использования ftp_chmod()
<?php
$file = 'public_html/index.php';
// установка соединения
$conn_id = ftp_connect($ftp_server);
// вход с именем пользователя и паролем
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// попытка изменить права доступа к файлу $file на 644
if (ftp_chmod($conn_id, 0644, $file) !== false) {
echo "Права доступа к файлу $file изменены на 644\n";
} else {
echo "Не удалось изменить права доступа к файлу $file\n";
}
// закрытие соединения
ftp_close($conn_id);
?>
ftp_chmod
cspiegl at kwask dot de
21-Apr-2008 09:30
21-Apr-2008 09:30
tiefenbrunner at obdev dot at
17-Dec-2007 02:19
17-Dec-2007 02:19
The "mode" parameter of the PHP5 ftp_chmod function is an integer value that is supposed to be given as an octal number, like the argument for the "chmod" command line tool.
Thus the sprintf must use the %o formatting character, so that the passed integer value is really represented as an octal number to the CHMOD site command for the FTP server.
So, IMHO, rabin's version is correct (it definitely worked for me).
Josh at jcr dot com
13-Sep-2007 07:13
13-Sep-2007 07:13
rabin's code works just fine as a replacement for ftp_chmod().
I would try that before trying cspiegl's solution for pre-php 5 installations.
cspiegl at KwasK dot de
31-Aug-2007 10:36
31-Aug-2007 10:36
Hi,
The commet with the "ftp_site" is not correct!
You must use it like this:
<?php
if (!function_exists('ftp_chmod')) {
function ftp_chmod($ftp_stream, $mode, $filename)
{
return ftp_site($ftp_stream, sprintf('CHMOD %u %s', $mode, $filename));
}
}
?>
rabin at rab dot in
23-May-2006 12:21
23-May-2006 12:21
As mentioned in the note below, the function posted by "hardy add mapscene dot com" works incorrectly if used with an octal mode, the way the php5 function is used.
This function works exactly like the the php5 one:
<?php
if (!function_exists('ftp_chmod')) {
function ftp_chmod($ftp_stream, $mode, $filename)
{
return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
}
}
?>
