Portál AbcLinuxu, 9. listopadu 2025 09:15
function FtpCopy($src, $dst) {
$server='xxx'; // ftp server
$connection = ftp_connect($server); // connection
// login to ftp server
$user = "xxx";
$pass = "xxx";
$result = ftp_login($connection, $user, $pass);
// check if connection was made
if ((!$connection) || (!$result)) {
return false;
exit();
}
// upload the file
$upload = ftp_put($connection, $dst, $src, FTP_BINARY);
ftp_chmod($connection,0666,$dst);
}
$source = "./SETUP.txt"; $dst = "./pics/"; FtpCopy($source, $dst);adresar pics ma nastavena prava 0777 a soubor SETUP.txt ma prava cteni pro vsechny... Nejake napady?
$source_file = "test.txt";
$destination_file = "pics/";
$ftp_server = "ftp.test.com";
$ftp_user_name = "test";
$ftp_user_pass = "test";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
Vse probehne v poradku, dokonce i test nahrani, ale soubor na serveru fyzicky neni :(
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.