ftp_nb_put
(PHP 4 >= 4.3.0, PHP 5)
ftp_nb_put — Salva un file sul server FTP in modalita' non bloccante
Descrizione
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.
Example#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);
}
?>
Example#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().