<?php
$file = "/home/user/myfile";
// サーバーに接続する
$ftp = ftp_connect('ftp.example.com');
$login_result = ftp_login($ftp, 'anonymous', 'user@example.com');
if (ftp_alloc($ftp, filesize($file), $result)) {
echo "Space successfully allocated on server. Sending $file.\n";
ftp_put($ftp, '/incoming/myfile', $file, FTP_BINARY);
} else {
echo "Unable to allocate space on server. Server said: $result\n";
}
ftp_close($ftp);
?>