ftp_raw

(PHP 5, PHP 7, PHP 8)

ftp_rawEnvia um comando arbritário a um servidor FTP

Descrição

ftp_raw(FTP\Connection $ftp, string $command): ?array

Envia um comando arbritário, especificado no parâmetro command, ao servidor FTP.

Parâmetros

ftp

Uma instância de FTP\Connection.

command

O comando a executar.

Valor Retornado

Retorna a resposta do servidor como um array de strings, ou null em caso de falha. Nenhuma interpretação é realizada na string de resposta, e ftp_raw() não determina se o comando foi bem sucedido .

Registro de Alterações

Versão Descrição
8.1.0 O parâmetro ftp agora espera uma instância de FTP\Connection; anteriormente, um resource era esperado.

Exemplos

Exemplo #1 Usando ftp_raw() para fazer o login em um servidor FTP manualmente.

<?php
$ftp
= ftp_connect("ftp.example.com");

/* Isto é o mesmo que:
ftp_login($ftp, "joeblow", "secret"); */
ftp_raw($ftp, "USER joeblow");
ftp_raw($ftp, "PASS secret");
?>

Veja Também

  • ftp_exec() - Solicita a execução de um comando no servidor FTP

add a note add a note

User Contributed Notes 3 notes

up
2
nightwalker85 at gmail dot com
18 years ago
<?
ftp_raw($ftpconn,"CLNT <client>");
?>

Is a good way to let the ftp-server know which client it's dealing with. Guess this can be useful if you're making a homemade ftp-client. Only do this if the ftp-server has responded to FEAT command with a response including CLNT.
up
2
www.bossftp.com
15 years ago
Note that the $command can not contains any illegal character such as \n, \r, \t, or this function will return NULL.

Try using the trim() before calling ftp_raw().

<?php
ftp_raw
($connid, trim($command));
?>
up
-1
WebSee.ru
14 years ago
How to realize the possibility of transferring data from one FTP-server to another via FXP?

<?php
// ...

$ansver = ftp_raw($ftp_conn1, 'PASV');

if (
intval($ansver[0]) == 227) {
   
ftp_raw($ftp_conn2, 'PORT '.substr($ansver[0], $n = strpos($ansver[0], '(') + 1, strpos($m[0], ')', $n) - $n));
   
ftp_raw($ftp_conn1, 'STOR '.$filename); // need asynchronously (non-blocking)
   
ftp_raw($ftp_conn2, 'RETR '.$filename);
}
?>
To Top