PHP ftp transfers files to the server
CopyCode The Code is as follows: <? PHP
// 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 ){
// Other code can be inserted.
Echo ".";
// Continue transmission...
$ Ret = ftp_nb_continue ($ my_connection );
}
If ($ RET! = Ftp_finished ){
Echo "Download error ...";
Exit (1 );
}
?>
delete a file using php ftp copy Code the code is as follows: $ file = 'public _ html/old.txt ';
// connect to the FTP server
$ conn_id = ftp_connect ('www .jb51.net ');
// verify the username 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 deleted successfully N ";
}else {
echo "failed to delete $ file N";
}< br> // disable FTP connection
ftp_close ($ conn_id );
?>
php ftp File Download copy Code the code is as follows: $ file = 'somefile.txt ';
// connect to the FTP server
$ conn_id = ftp_connect ($ ftp_server );
// verify the 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 size is $ res Byte";
}else {
echo "failed to get remote file size ";
}< br> // close the FTP connection
ftp_close ($ conn_id);
?>