HTML 機能のコードをいくつか手伝ってもらっています。
Web サイト (txtName,txtBody) の 2 つのテキスト ボックスから情報を取得し、PHP を使用してこれらのテキスト ボックスの内容を ftp サーバー上のファイルに保存したいと考えています。
誰かがこれを行うために正しい方向に私を向けることができますか?
ありがとう
ダゴンが言うように、ファイルのコンテンツを使用してこれを達成できます。以下は簡単な例です。
<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
//Assign txtName to variable.
$name = $_POST['txtName'];
// Append a new person to the file
$current .= $name;
// Write the contents back to the file
file_put_contents($file, $current);
?>
対処する場合は、 http://www.php.net/manual/en/function.ftp-fput.phpftp
を使用する必要があります
$file = $_POST['txtName'];
file_put_contents($file, $_POST['txtBody']);
$fp = fopen($file, 'r');
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
echo "Successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
ftp_close($conn_id);
fclose($fp);