ftp_rmdir()

It removes a directory on the FTP server

Example

<?php

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

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

ftp_rmdir($ftpId, “test”) or die(“Failed”);

ftp_quit($ftpId);

?>

ftp_rename()

It renames a file or a directory on the FTP server

Example

<?php

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

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

ftp_rename($ftpId, $oFile, $nFile) or die(“Failed”);

ftp_quit($ftpId);

?>

ftp_rawlist()

It returns a detailed list of files in the given directory

Example

<?php

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

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

$result = ftp_rawlist($ftpId, ‘/’);

ftp_quit($ftpId);

echo “<pre>”;print_r($result);

?>

ftp_raw()

It sends an arbitrary command to an FTP server

Example

<?php

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

ftp_raw($ftpId, “USER user”);

ftp_raw($ftpId, “PASS pass”);

ftp_quit($ftpId);

?>

 

 

ftp_quit()

Its an alias ftp_close() and  closes ftp conection

Example

<?php

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

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

echo ftp_pwd($ftpId)

ftp_quit($ftpId);

?>

ftp_pwd()

It  returns the current directory name

Example

<?php

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

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

echo ftp_pwd($ftpId)

ftp_close($ftpId);

?>

ftp_put()

It uploads a file to the FTP server

Example

<?php

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

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

ftp_put($ftpId, $rFile, $lFile, FTP_ASCII) or die(“Failed”);

ftp_close($ftpId);

?>

ftp_pasv()

It turns passive mode on or off

Example

<?php

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

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

ftp_pasv($conn_id, false);

ftp_close($ftpId);

?>

ftp_nlist()

It returns a list of files in the given directory

Example

<?php

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

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

$data = ftp_nlist($ftpId, “.”);

ftp_close($ftpId);

?>

 

ftp_nb_put()

It stores a file on the FTP server

Example

<?php

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

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

$ret = ftp_nb_put($ftpId, “serverFile”, “localfile”, FTP_BINARY);

while ($dest == FTP_MOREDATA) {

  $dest = ftp_nb_continue($ftpId);

}

  ftp_close($ftpId);

  fclose($fp);

?>