ftp_raw

(PHP 5, PHP 7, PHP 8)

ftp_rawEnvoie une commande FTP brute

Description

ftp_raw(resource $ftp, string $command): array

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

Liste de paramètres

ftp

La ressource de connexion FTP.

command

La commande à exécuter.

Valeurs de retour

Retourne la réponse du serveur en tant que tableau de chaînes. Aucune analyse n'est faite sur la chaîne réponse, ni si ftp_raw() détermine si la commande a réussi.

Exemples

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

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

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

ftp_raw($fp"USER joeblow");
ftp_raw($fp"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
19 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
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);
}
?>
up
0
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));
?>
To Top