PHP ftp_put()Functions


PHP FTP 参考手册Complete PHP FTP Reference Manual

Definition and Usage

The ftp_put() function uploads a local file to the FTP server.

If successful, the function returns TRUE. If it fails, it returns FALSE.

Syntax

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

Parameters Description
ftp_connection Required. Specifies the FTP connection to use.
remote Required. Specifies the file to upload to the FTP server.
local Required. Specifies the path of the file to upload.
mode Required. Specifies the transfer mode. Possible values:
  • FTP_ASCII
  • FTP_BINARY
resume Optional. Specifies where in the local file to start copying. Default is 0.


Example

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

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

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

ftp_close($conn);
?>

The above code will output:

1


PHP FTP 参考手册Complete PHP FTP Reference Manual Other Extensions