Latest web development tutorials

PHP ftp_nb_put () function

PHP FTP Reference Complete PHP FTP Reference

Definition and Usage

ftp_nb_put () function to upload a local file to the FTP server. (Non-blocking)

The function returns one of the following values:

  • FTP_FAILED (transmission / acquisition failure)
  • FTP_FINISHED (transmission / acquisition success)
  • FTP_MOREDATA (send / get underway)

And ftp_put () is different from the function asynchronously obtain the file. This means that your program can perform other operations in the file download.

grammar

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

参数 描述
ftp_connection 必需。规定要使用的 FTP 连接。
remote 必需。规定上传到 FTP 服务器上保存的文件。
local 必需。规定要上传的文件的路径。
mode 必需。规定传输模式。可能的值:
  • FTP_ASCII
  • FTP_BINARY
resume 可选。规定在本地文件中的何处开始复制。默认是 0。


Examples

This example is copied from the "source.txt" text to "target.txt" in:

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

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

ftp_close($conn);
?>


PHP FTP Reference Complete PHP FTP Reference