PHP ftp_nb_fput()Functions
Complete PHP FTP Reference Manual
Definition and Usage
The ftp_nb_fput() function uploads a local opened file 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 completed successfully)
- FTP_MOREDATA (send/get is in progress)
Unlike ftp_fput(), this function retrieves the file asynchronously. This means 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 use. |
| remote | Required. Specifies the file to be uploaded and saved on the FTP server. |
| local | Required. Specifies the open file to upload. |
| mode | Required. Specifies the transfer mode. Possible values:
|
| resume | Optional. Specifies where to start copying in the local file. Default is 0. |
Examples
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);
?>
$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);
?>
Complete PHP FTP Reference Manual Other Extensions