Forum und email

ftp_nb_put

(PHP 4 >= 4.3.0, PHP 5)

ftp_nb_put — Grava um arquivo no servidor FTP (sem bloquear)

Descrição

int ftp_nb_put ( resource $ftp_stream , string $remote_file , string $local_file , int $mode [, int $startpos ] )

ftp_nb_put() grava um arquivo local em um servidor FTP.

A diferença entre esta função e ftp_put() é que esta função envia o arquivo de forma assincronoma, assim o seu programa pode realizar outras operações enquanto o seu arquivo esta sendo carregado.

Parâmetros

ftp_stream

O identificador com a conexão FTP.

remote_file

O caminho para o arquivo remoto.

local_file

O caminho para o arquivo local.

mode

O modo de transferência. Deve ser FTP_ASCII ou FTP_BINARY.

startpos

Valor Retornado

Retorna FTP_FAILED ou FTP_FINISHED ou FTP_MOREDATA.

Exemplos

Example#1 Exemplo ftp_nb_put()

<?php

// Initiate the Upload
$ret ftp_nb_put($my_connection"test.remote""test.local"FTP_BINARY);
while (
$ret == FTP_MOREDATA) {
   
   
// Do whatever you want
   
echo ".";

   
// Continue uploading...
   
$ret ftp_nb_continue($my_connection);
}
if (
$ret != FTP_FINISHED) {
   echo 
"There was an error uploading the file...";
   exit(
1);
}
?>

Example#2 Continuando um upload com ftp_nb_put()

<?php

// Initiate
$ret ftp_nb_put($my_connection"test.remote""test.local"
                      
FTP_BINARYftp_size("test.remote"));
// OR: $ret = ftp_nb_put($my_connection, "test.remote", "test.local", 
//                           FTP_BINARY, FTP_AUTORESUME);

while ($ret == FTP_MOREDATA) {
   
   
// Do whatever you want
   
echo ".";

   
// Continue uploading...
   
$ret ftp_nb_continue($my_connection);
}
if (
$ret != FTP_FINISHED) {
   echo 
"There was an error uploading the file...";
   exit(
1);
}
?>