ftp_nb_get()

It retrieves a file from the FTP server and writes it to a local file

Example

<?php

$fp = fopen(“test.txt”, ‘w’);

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

$ret = ftp_nb_get($ftpId, $fp, “test”, FTP_BINARY, filesize(“test”));

while ($dest == FTP_MOREDATA) {

  $dest = ftp_nb_continue($ftpId);

}

  ftp_close($ftpId);

  fclose($fp);

?>

ftp_nb_fput()

It stores a file from an open file to the FTP server

Example

<?php

$fp = fopen(“test.txt”, ‘w’);

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

$dest = ftp_nb_fput($conn_id, “text.txt”, $fp, FTP_BINARY);

while ($dest == FTP_MOREDATA) {

  $dest = ftp_nb_continue($ftpId);

}

  ftp_close($ftpId);

  fclose($fp);

?>

ftp_nb_fget()

It retrieves a file from the FTP server and writes it to an open file

Example

<?php

$fp = fopen(“test.txt”, ‘w’);

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

$dest = ftp_nb_fget($conn_id, $fp, “test.txt”, FTP_BINARY);

while ($dest == FTP_MOREDATA) {

  $dest = ftp_nb_continue($ftpId);

}

ftp_close($ftpId);

fclose($fp);

?>

ftp_nb_continue()

Continues retrieving/sending a file

Example

<?php

$fp = fopen(“test.txt”, ‘w’);

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

$dest = ftp_nb_fget($conn_id, $fp, “test.txt”, FTP_BINARY);

while ($dest == FTP_MOREDATA) {

  $dest = ftp_nb_continue($ftpId);

}

ftp_close($ftpId);

fclose($fp);

?>

ftp_mkdir()

It creates a directory on the FTP server

Example

<?php

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

ftp_mkdir($ftpId, “tets”) or die(“Failed”);

ftp_close($ftpId);

?>

ftp_mdtm()

It returns the last modified time of the given file

Example

<?php

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

echo date(“D M Y H i s”,ftp_mdtm($ftpId, “test.txt”));

   ftp_close($ftpId);

?>

ftp_get()

It downloads a file from the FTP server

Example

<?php

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

ftp_get($ftpId, “local.text”, ‘server.txt’, FTP_BINARY) or die(“Failed”);

ftp_close($ftpId);

?>

ftp_get_option()

It retrieves various runtime behaviours of the current FTP stream

Example

<?php

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

$disconnect = ftp_get_option($ftpId, FTP_TIMEOUT_SEC);

ftp_close($ftpId);

?>

ftp_fput()

It uploads from an open file to the FTP server

Example

<?php

$fp = fopen(“test.txt”, ‘r’);

$ftpId = ftp_connect(‘ftp.phpcodez.com’);

$login_result = ftp_login($ftpId, ‘anonymous’, ‘user@phpcodez.com’);

ftp_fput($ftpId, “”test.txt””, $fp, FTP_ASCII)

ftp_close($ftpId);

fclose($fp);

?>