PHP ftp_nb_fput() function
Definition and Usage
The ftp_nb_fput() function uploads an open file and saves it as a file (non-blocking) on the FTP server.
This function returns the following values:
- FTP_FAILED (send/receive failed)
- FTP_FINISHED (send/receive completed)
- FTP_MOREDATA (send/receive in progress)
With ftp_fput() Different, this function retrieves the file asynchronously. This means that your program can perform other operations while the file is being downloaded.
Syntax
ftp_nb_fput(ftp_connection,remote,local,mode,resume)
Parameters | Description |
---|---|
ftp_connection | Required. Specifies the FTP connection to be used (identifier of the FTP connection). |
remote | Required. The file name to be uploaded to the server. |
local | Required. Specifies the handle of the file opened. |
mode |
Required. Specifies the transmission mode. Possible values include:
|
resume | Required. Specifies where to start copying in the local file. 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); ?>