PHP ftp_fput()Functions


PHP FTP 参考手册Complete PHP FTP Reference Manual

Definition and Usage

The ftp_fput() function uploads a local file that is already open and saves it as a file on the FTP server.

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

Syntax

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

Parameter Description
ftp_connection Required. Specifies the FTP connection to use.
remote Required. Specifies the file to be uploaded to the FTP server and saved.
local Required. Specifies the open file to upload.
mode Required. Specifies the transfer mode. Possible values:
  • FTP_ASCII
  • FTP_BINARY
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");

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

ftp_close($conn);
?>

The code above will output:

1


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