WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP ftp_nb_fput() function


Definition and usage

The ftp_nb_fput () function uploads an open file locally and saves it as a file on the FTP server. (Non-blocking)

This function returns one of the following values:

  • FTP_FAILED (send /get failed)
  • FTP_FINISHED (send /get successfully)
  • FTP_MOREDATA (Send /Get is in progress)

Unlike ftp_fput (), this function fetches a file asynchronously. This means that your program can perform other operations while the file is downloading.

Syntax

ftp_nb_fput (ftp_connection, remote, local, mode, resume)

parameters description
ftp_connection Required. Specifies the FTP connection to use.
remote Required. Specifies the file to be uploaded to the FTP server.
local Required. Specifies the open file to upload.
mode Required. Specify the transmission mode. Possible values:
  • FTP_ASCII
  • FTP_BINARY
resume Optional. Specifies where in the local file to start copying. The default is 0.


Example

This example copies text from "source.txt" to "target.txt":

<?php
$source = fopen("source.txt","r");

$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");

ftp_nb_fput($conn,"target.txt",$source,FTP_ASCII);

ftp_close($conn);
?>