php ftp transfer files to server
Copy 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) {
// You can insert other code
echo "." ;
// Continue transmitting...
$ret = ftp_nb_continue ($my_connection);
}
if ($ret != FTP_FINISHED) {
echo "Download error..." ;
exit(1);
}
?>
php ftp delete file
Copy the 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 "Deletion of $file file failed";
}
//Close FTP connection
ftp_close($conn_id);
?>
php ftp download file
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 specified file Size
$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);
?>
http://www.bkjia.com/PHPjc/322020.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322020.htmlTechArticlephp ftp transfer files to the server. Copy the code as follows: ?php // Start $ret = ftp_nb_get ($my_connection, "test", "README", FTP_BINARY, filesize("test")); // or: $ret = ftp_nb_...