PHP FTP transfer files to server
Copy Code code as follows:
<?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
Copy Code code as follows:
<?php
$file = ' public_html/old.txt ';
Connecting to an FTP server
$conn _id = ftp_connect (' www.jb51.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
Copy Code code as follows:
<?php
$file = ' somefile.txt ';
//Connection FTP server
$conn _id = ftp_connect ($ftp _server);
//Verify user name and password www.jb51. NET
$login _result = Ftp_login ($conn _id, $ftp _user_name, $ftp _user_pass);
//Get the size of the specified file
$res = ftp_size ($conn _id, $file);
if ($res!=-1) {
echo "$file file size is $res byte";
} else {
echo "failed to get remote file size";
}
//Close FTP connection
Ftp_close ($conn _id);
?>