In this small post I will show you how to upload file on the ftp server using PHP. As we know there are many ftp function in PHP but whenever you want to upload file in ftp using PHP at that time ftp put function is useful.
Here, we will upload file to the FTP server in PHP.
ftp_put(ftp_conn, remote_file, local_file, mode, startpos);
ftp_conn — ftp_conn is required parameter and it is use to specifies the FTP connection.
remote_file — remote_file is required parameter and it is use to specifies the file path to upload path.
local_file — local_file is required parameter and it is use to specifies the path of the file to upload.
mode — mode is optional parameter and it is use to specifies the transfer mode. It has 2 possible values: 1) FTP_ASCII 2) FTP_BINARY.
startpos — startpos is optional parameter and it is use to specifies the position in the remote file to start uploading to.
<?php// connect to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");//login to FTP server
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);$file = "localfile.txt";// upload file
if (ftp_put($ftp_conn, "serverfile.txt", $file, FTP_ASCII))
echo "Successfully uploaded $file.";
echo "Error uploading $file.";
}// close connection
You may also like :
Bootstrap Date Range Picker Example
In this small tutorial i will show you how to implement bootstrap date range picker example, bootstrap date range…
How To Send Email With Attachment In Laravel 8
In this tutorial i will show you how to send email with attachment in laravel 8. As we all know mail functionalities…
Thank you for the reading…!!