HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /var/www/html/amberconcept/test_ftp.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$ftp_server = "ftp.winghung.com";
$ftp_user_name = "whmis";
$ftp_user_pass = "WHServer&*)1";

$ftp = ftp_connect($ftp_server); 

// login with username and password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass); 

$passive = true;
echo "Setting Passive Mode=$passive<br>";
ftp_pasv($ftp, $passive);

// check connection
if ((!$ftp) || (!$login_result)) { 
    echo "FTP connection has failed!<br>";
    echo "Attempted to connect to $ftp_server for user $ftp_user_name<br>"; 
    exit; 
} else {
    echo "Connected to $ftp_server, for user $ftp_user_name<br>";
}

$dir = "Test/hkmis";
if (ftp_mkdir($ftp, $dir)) {
 	echo "successfully created $dir<br>";
} else {
	echo "There was a problem while creating $dir<br>";
}

$source_file = "/var/www/html/amberconcept/document/po/PO2202.pdf";
$destination_file = $dir."/PO2202.pdf";
// upload the file
$upload = ftp_put($ftp, $destination_file, $source_file, FTP_BINARY); 

// check upload status
if (!$upload) { 
    echo "FTP upload has failed!<br>";
} else {
    echo "Uploaded $source_file to $ftp_server as $destination_file<br>";
}

// close the FTP connection 
ftp_close($ftp);