php ftp transfer files to the server
Copy the code The code is as follows:
// Start
$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) {
// can be inserted Other codes
echo ".";
// Continue to send...
$ret = ftp_nb_continue ($my_connection);
}
if ($ret != FTP_FINISHED) {
echo "Download error...";
exit (1);
}
?>
Copy code The code is as follows:
$file = 'public_html/old.txt';
// Connect to FTP server
$conn_id = ftp_connect('www.jb51.net');
// Verify username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// Delete specified file
if ( ftp_delete($conn_id, $file)) {
echo "$file file deleted successfully";
} else {
echo "$file file deleted failed";
}
// Close FTP connection
ftp_close($conn_id) ;
?>
Copy code The code is as follows:
$file = 'somefile.txt';
// Connect to FTP server
$conn_id = ftp_connect($ftp_server);
//Verify username 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 bytes";
} else {
echo "Failed to obtain remote file size";
}
//Close FTP connection
ftp_close($conn_id);
?>
The above introduces the example code of the software to recover files deleted from the Recycle Bin by connecting to FTP under PHP to upload, download and delete files, including the content of the software to recover files deleted from the Recycle Bin. I hope it will be helpful to friends who are interested in PHP tutorials.