Directly from bsd FTP manual pages:
The PASV command requests that the remote server open a port for the data connection and return the address of that port. The remote server listens on that port and the client connects to it.
When using the more traditional PORT command, the client listens on a port and sends that address to the remote server, who connects back to it. Passive mode is useful when using ftp through a gateway router or host that controls the directionality of traffic. (Note that though ftp servers are required to support the PASV command by RFC 1123, some do not.)
ftp_pasv
(PHP 4, PHP 5)
ftp_pasv — Habilita o deshabilita el modo pasivo
Descripción
bool ftp_pasv
( resource $secuencia_ftp
, bool $pasv
)
ftp_pasv() habilita o deshabilita el modo pasivo. En modo pasivo, las conexiones de datos son iniciadas por el cliente, en lugar del servidor. Puede requerirse si el cliente se encuentra detrás de un firewall.
Por favor note que ftp_pasv() únicamente puede llamarse después de un inicio de sesión exitoso, de otra forma fallará.
Lista de parámetros
- secuencia_ftp
-
El identificador de enlace de la conexión FTP.
- pasv
-
Si es TRUE, el modo pasivo es habilitado, de lo contrario es deshabilitado.
Valores retornados
Devuelve TRUE si todo se llevó a cabo correctamente, FALSE en caso de fallo.
Ejemplos
Example #1 Ejemplo de ftp_pasv()
<?php
$archivo = 'algunarchivo.txt';
$archivo_remoto = 'leame.txt';
// configurar conexión básica
$id_con = ftp_connect($servidor_ftp);
// iniciar sesión con nombre de usuario y contraseña
$resultado_login = ftp_login($id_con, $ftp_nombre_usuario, $ftp_contrasenya);
// habilitar modo pasivo
ftp_pasv($id_con, true);
// cargar un archivo
if (ftp_put($id_con, $archivo_remoto, $archivo, FTP_ASCII)) {
echo "se ha cargado $archivo con éxito\n";
} else {
echo "Hubo un problema al cargar $archivo\n";
}
// cerrar la conexión
ftp_close($id_con);
?>
ftp_pasv
ybourbeau at edison dot ca
08-Apr-2002 06:28
08-Apr-2002 06:28
03-Apr-2002 08:19
PASV: For ftp users behind firewall, the server LISTEN for a connection.
Non-PASV: The client LISTEN for a connection from server.
