ftp_nb_put
(PHP 4 >= 4.3.0, PHP 5)
ftp_nb_put -- Salva un file sul server FTP in modalita' non bloccante
Descrizione
int
ftp_nb_put ( resource ftp_stream, string remote_file, string local_file, int mode [, int startpos] )
La funzione ftp_nb_put() salva local_file sul server FTP come remote_file. La modalita' di trasferimento, mode specificata deve essere FTP_ASCII oppure FTP_BINARY. La differenza tra questa funzione e la funzione ftp_put() e' che questa funzione trasferisce il file in modo asincrono, cosicche' il programma puo' eseguire altre operazioni durante il trasferimento.
Restituisce FTP_FAILED, FTP_FINISHED, oppure FTP_MOREDATA.
Esempio 1. Esempio di funzione ftp_nb_put() <?php
// Inizia il trasferimento $ret = ftp_nb_put($my_connection, "test.remote", "test.local", FTP_BINARY); while ($ret == FTP_MOREDATA) { // esegue altre operazioni echo ".";
// continua il trasferimento... $ret = ftp_nb_continue($my_connection); } if ($ret != FTP_FINISHED) { echo "Errore nel trasferimento del file..."; exit(1); } ?> |
|
Esempio 2. Ripresa di un trasferimento con ftp_nb_put() <?php
// Inizio $ret = ftp_nb_put($my_connection, "test.remote", "test.local", FTP_BINARY, ftp_size("test.remote")); // oppure: $ret = ftp_nb_put($my_connection, "test.remote", "test.local", // FTP_BINARY, FTP_AUTORESUME);
while ($ret == FTP_MOREDATA) { // esegue altre operazioni echo ".";
// Continua il trasferimento... $ret = ftp_nb_continue($my_connection); } if ($ret != FTP_FINISHED) { echo "Errore nel trasferimento del file..."; exit(1); } ?> |
|
Vedere anche ftp_nb_fput(), ftp_nb_continue(), ftp_put(), e ftp_fput().