Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
ftp_fput() function in PHP
The ftp_fget() function is used to upload from an open file and saves it to a file on the FTP server.
Syntax
ftp_fput(con,remote_file,open_file,mode,startpos);
Parameters
con − The FTP connection
remote_file − The file path to upload to
open_file − The open local file
mode − The transfer mode
startpos − The position to begin downloading from
Return
The ftp_fget() function returns TRUE on success and FALSE on failure.
Example
The following is an example wherein we will download server file “demo.txt” and save it to open local file “new.txt” −
<?php
$ftp_server="192.168.0.4";
$ftp_user="amit";
$ftp_pass="tywg61gh";
$con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($con, $ftp_user, $ftp_pass);
$my_file = "demo.txt";
$local_file = "new.txt";
$file_pointer = fopen($local_file,"r");
if (ftp_fput($ftp_conn, $my_file, $file_pointer, FTP_ASCII) {
echo "Uploaded!";
} else {
echo "Error in uploading file!";
}
ftp_close($con);
fclose($file_pointer);
?> Advertisements
