PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ftp_close> <ftp_chdir
Last updated: Fri, 22 Aug 2008

view this page in

ftp_chmod

(PHP 5)

ftp_chmodEstablecer permisos en un archivo via FTP

Descripción

int ftp_chmod ( resource $secuencia_ftp , int $modo , string $nombre_archivo )

Establece los permisos sobre el archivo remoto especificado a modo .

Lista de parámetros

secuencia_ftp

El identificador de enlace de la conexión FTP.

modo

Los nuevos permisos, dados como un valor octal.

nombre_archivo

El archivo remoto.

Valores retornados

Devuelve los nuevos permisos del archivo en caso de tener éxito, o FALSE si ocurre un error.

Ejemplos

Example #1 Ejemplo de ftp_chmod()

<?php
$archivo 
'public_html/index.php';

// configurar una conexion basica
$id_con ftp_connect($servidor_ftp);

// iniciar sesion con nombre de usuario y contrasenya
$resultado_login ftp_login($id_con$nombre_usuario_ftp$contrasenya_ftp);

// intentar chmod en $archivo con el valor 644
if (ftp_chmod($id_con0644$archivo) !== false) {
 echo 
"se efectu&oacute; chmod sobre $archivo satisfactoriamente con el valor 644\n";
} else {
 echo 
"no se pudo realizar chmod sobre $archivo\n";
}

// cerrar la conexion
ftp_close($id_con);
?>

Ver también



ftp_close> <ftp_chdir
Last updated: Fri, 22 Aug 2008
 
add a note add a note User Contributed Notes
ftp_chmod
cspiegl at kwask dot de
21-Apr-2008 09:30
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!
tiefenbrunner at obdev dot at
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
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
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
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));
    }
}
?>

ftp_close> <ftp_chdir
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites