I have a HTML form containing variables which are passed to a php file to generate a CSV file. This is working and once form is submitted it downloads the generated CSV file. However, I would like the CSV file to be uploaded to a remote SFTP server instead of beeing downloaded when submit action is made.
This is my current php file:
<?php
//give a filename
$filename = "order.csv";
//set headers to download file
header( 'Content-Type: text/csv' );
header( 'Content-Disposition: attachment;filename='.$filename);
$file = fopen('php://output', 'w');
//set the column names
$cells[] = array(
'address',
'city',
'phone',
'email' );
//pass all the form values
$cells[] = array(
$_POST['address'],
$_POST['city'],
$_POST['phone'],
$_POST['email']);
foreach($cells as $cell){
fputcsv($file,$cell);
}
fclose($file);
?>