The ftp_fput() function uploads an open file locally and saves it as a file on the FTP server.
If successful, the function returns TRUE. If it fails, returns FALSE.
ftp_fput(ftp_connection,remote,local,mode,resume)
| parameter | describe |
|---|---|
| ftp_connection | Required. Specifies the FTP connection to use. |
| remote | Required. Specifies uploading files saved on the FTP server. |
| local | Required. Specifies the open file to upload. |
| mode | Required. Specifies the transmission mode. Possible values: FTP_ASCII FTP_BINARY |
| resume | Optional. Specifies where in the local file to start copying. The default is 0. |
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 above code will output:
1