我正在使用phpexcel生成CSV文件,并且能够下载和保存csv文件,但无法将phpexcel生成的csv文件直接保存到ftp服务器而不保存,请指导我不保存就上传phpexcel生成的csv文件我的本地代码在下面
error_reporting(E_ALL);
include 'PHPExcel.php';
include PHPExcel/Writer/CSV.php';
require_once "PHPExcel/IOFactory.php";
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1',"1");
$objPHPExcel->getActiveSheet()->setCellValue('B1',"2");
$objPHPExcel->getActiveSheet()->setCellValue('A2',"3");
$filename='gs.csv'; //just some random filename
header('Content-Type: text/CSV');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save('php://output');
$ftp_server='ftp.exc.in';
$ftp_user_name='user';
$ftp_user_pass='pass';
$local_file=fopen('php://temp', 'r+');
$remote_file="/test/gs.csv";
rewind($local_file);
$ftp_conn=ftp_connect($ftp_server);
@$login_result=ftp_login($ftp_conn, $ftp_user_name, $ftp_user_pass);
if($login_result) $upload_result=ftp_fput($ftp_conn, $remote_file, $local_file, FTP_ASCII);
ftp_close($ftp_conn);
fclose($local_file);
上面的代码生成了csv文件,但它要求下载,但是我只需要上传csv文件而不在本地保存