I want to create a CSV file in a remote server in a certain folder. I have the FTP details, and the code for creating the CSV ready, but my problem is I am unable to save that CSV in that remote server. I used below code to connect to FTP:
$ftp_server = "127.0.0.1"; // FTP Server Address (exlucde ftp://)
$ftp_user_name = "username"; // FTP Server Username
$ftp_user_pass = "password"; // Password
// Connect to FTP Server
$conn_id = ftp_connect($ftp_server);
// Login to FTP Server
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
Now I want to save the file to the connection made above.
Currently below is the code that i used to open a csv stream.
$structure = './orderexport/'.$order_date;
if (!mkdir($structure, 0777, true)) {
$filename = "orderexport/".$order_date."/test_".$order_id.".csv";
} else{
$filename = "orderexport/".$order_date."/test_".$order_id.".csv";
}
$fp = fopen($filename, 'w');
Is there anything I need to do on csv end too to save it to remote server?