1

一部のデータをエクスポートし、ファイルを作成して、データをファイルに書き込んでいます...

私のファイルは ftp サーバーに表示されますが、空です...

これがコードです。

//Connect to the FTP server
$ftpstream = @ftp_connect('localhost');

//Login to the FTP server
$login = @ftp_login($ftpstream, 'some_login', 'some_password');
if($login) {
//We are now connected to FTP server.
//Create a temporary file
$temp = tmpfile();

//Upload the temporary file to server
@ftp_fput($ftpstream, '/httpdocs/itineraryschedule.txt', $temp, FTP_ASCII);

//Make the file writable by all
ftp_site($ftpstream,"CHMOD 0777 /httpdocs/itineraryschedule.txt");

//Write to file
$fp = fopen('var/www/vhosts/cruiseandmaritime.com/httpdocs/itineraryschedule.txt', 'w');
fputs($fp, 'some data');
fclose($fp);

//Make the file writable only to owner
ftp_site($ftpstream,"CHMOD 0644 /httpdocs/itineraryschedule.txt");
}

私は困惑しています!

リッチ :)

4

2 に答える 2

2

@ を削除して、エラーが発生するかどうかを確認します

あなたの道も

$fp = fopen('var/www/vhosts/cruiseandmaritime.com/httpdocs/itineraryschedule.txt', 'w');

少しずれているようです

$fp = fopen('/var/www/vhosts/cruiseandmaritime.com/httpdocs/itineraryschedule.txt', 'w'); 多分?

于 2012-06-29T09:57:43.057 に答える
0

使用しているライブラリがわかりません。しかし、コードは、アップロードする前に作成したばかりの tmpfile() をアップロードしているようです。それが空っぽの理由です。

FTPサーバーにプッシュしたいデータをローカルに書いているようです。var/www/vhosts/cruiseandmaritime.com/httpdocs/itineraryschedule.txtちょうどあなたのマシンにあります。でアップロードしてみてくださいftp_fput-これでうまくいくはずです。

于 2012-06-29T09:57:27.097 に答える