ftp_raw

(PHP 5, PHP 7, PHP 8)

ftp_rawEnvoie une commande FTP brute

Description

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

ftp_raw() envoie la commande FTP brute command au serveur FTP identifié par ftp.

Liste de paramètres

ftp

Une instance de FTP\Connection.

command

La commande à exécuter.

Valeurs de retour

Retourne la réponse du serveur en tant qu'un tableau de chaînes, ou null en cas d'échec. Aucune analyse n'est faite sur la chaîne de réponse, ni si la commande a réussi.

Historique

Version Description
8.1.0 La paramètre ftp attend désormais une instance de FTP\Connection ; auparavant, une ressource était attendu.

Exemples

Exemple #1 Utilisation de ftp_raw() pour s'identifier manuellement sur un serveur FTP

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

/* Ceci est l'équivalent de :
ftp_login($ftp, "joeblow", "secret");
*/

ftp_raw($ftp, "USER joeblow");
ftp_raw($ftp, "PASS secret");
?>

Voir aussi

  • ftp_exec() - Exécute une commande sur un serveur 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