오케이 그래서 브라우저에서 실행될 때 스크립트가 실행되어 내 데이터베이스에서 csv 파일을 만듭니다.대신 데이터베이스에서 csv 내보내기를 다운로드하고 ftp를 통해 서버에 파일을 작성하십시오.
하지만 내 서버에서 다른 서버로 파일을 게시하고 싶습니다.
나는이 코드로 해보려고했지만 작동하지 않는 것으로 기록 된 파일이 없습니다. FTP 계정 세부 정보가 잘못되어도 OK가 다시 돌아옵니다.
// header("Content-type: application/octet-stream");
// header("Content-Disposition: attachment; filename=sailings.txt");
// header("Pragma: no-cache");
// header("Expires: 0");
// print "$header\n$data";
//Connect to the FTP server
$ftpstream = ftp_connect('ftp server address');
//Login to the FTP server
$login = ftp_login($ftpstream, 'user', 'password');
if($login) {
echo "logged in ok";
//We are now connected to FTP server.
//Create a temporary file
$temp = tmpfile();
fwrite($temp, $header."\n");
fwrite($temp, $data);
fseek($temp, 0);
echo fread($temp, 0);
//Upload the temporary file to server
ftp_fput($ftpstream, '/sailings.txt', $temp, FTP_ASCII);
//Make the file writable only to owner
ftp_site($ftpstream,"CHMOD 0644 /sailings.txt");
}
//Ftp session end
fclose($temp);
ftp_close($ftpstream);
제발 아무도 알려 줄 수 없나요?
감사
리치 :
실제로 연결되어 있습니까? 계속하기 전에 $ ftpstream을 false로 테스트 해보십시오. –