ftp_nb_get
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
ftp_nb_get — Recupera un file dal server FTP e lo scrive su un file locale in modalita' non bloccante
Descrizione
ftp_nb_get(
resource $ftp_stream
,
string $local_file
,
string $remote_file
,
int $mode
,
int $resumepos
= ?
): int
Restituisce FTP_FAILED
, FTP_FINISHED
, oppure
FTP_MOREDATA
.
Example #1 Esempio di funzione ftp_nb_get()
<?php
// Inizia lo scaricamento
$ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY);
while ($ret == FTP_MOREDATA) {
// esegue altre operazioni
echo ".";
// Continua lo scaricamento...
$ret = ftp_nb_continue($my_connection);
}
if ($ret != FTP_FINISHED) {
echo "Errore nello scaricamento del file...";
exit(1);
}
?>
Example #2 Ripresa di uno scaricamento con ftp_nb_get()
<?php
// Inizio
$ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY,
filesize("test"));
// oppure: $ret = ftp_nb_get($my_connection, "test", "README",
// FTP_BINARY, FTP_AUTORESUME);
while ($ret == FTP_MOREDATA) {
// esegue altre operazioni
echo ".";
// Continua lo scaricamento...
$ret = ftp_nb_continue($my_connection);
}
if ($ret != FTP_FINISHED) {
echo "Errore nello scaricamento del file...";
exit(1);
}
?>
Example #3
Ripresa di uno scaricamento dalla posizione 100 su un nuovo
file con ftp_nb_get()
<?php
// Esclusione di Autoseek (ricerca automatica)
ftp_set_option($my_connection, FTP_AUTOSEEK, false);
// Inizio
$ret = ftp_nb_get($my_connection, "newfile", "README", FTP_BINARY, 100);
while ($ret == FTP_MOREDATA) {
/* ... */
// Continua lo scaricamento...
$ret = ftp_nb_continue($my_connection);
}
?>
Nell'esempio precedente, "newfile" e' 100 bytes piu' piccolo
di "README" sul server FTP perche' la lettura e' iniziata
dall'offset 100. Se
FTP_AUTOSEEK
non fosse stata disabilitata, i primi 100 bytes di
"newfile" sarebbero stati '\0'
.
Vedere anche ftp_nb_fget(),
ftp_nb_continue(),
ftp_get(), e ftp_fget().