PHP Tutorial FTP transfer files to server
<?php
Begin
$ret = Ftp_nb_get ($my _connection, "test", "README", Ftp_binary,
FileSize ("test"));
Or: $ret = Ftp_nb_get ($my _connection, "test", "README",
Ftp_binary, Ftp_autoresume);
while ($ret = = Ftp_moredata) {
You can insert additional code
echo ".";
Continue to send ...
$ret = ftp_nb_continue ($my _connection);
}
if ($ret!= ftp_finished) {
echo "Download error ...";
Exit (1);
}
?>
PHP FTP Delete file
<?php
$file = ' public_html/old.txt ';
Connecting to an FTP server
$conn _id = ftp_connect (' www.111cn.net ');
Verifying user name and password
$login _result = Ftp_login ($conn _id, $ftp _user_name, $ftp _user_pass);
Delete the specified file
if (Ftp_delete ($conn _id, $file)) {
echo "$file file Delete succeeded n";
} else {
echo "Delete $file file failed n";
}
Turn off FTP connections
Ftp_close ($conn _id);
?>
PHP ftp Download file
<?php
$file = ' somefile.txt ';
Connecting to an FTP server
$conn _id = ftp_connect ($ftp _server);
Verify user name and password www.111cn.net
$login _result = Ftp_login ($conn _id, $ftp _user_name, $ftp _user_pass);
Gets the size of the specified file
$res = Ftp_size ($conn _id, $file);
if ($res!=-1) {
echo "$file file size is $res byte";
} else {
echo "Get remote file size failed";
}
Turn off FTP connections
Ftp_close ($conn _id);
?>