Tag Archives: FTP

ftp_close

It closes an FTP connection

Example

<?php

$fName=”test”;

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

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

ftp_chmod($ftpId, 0777,$fName or die(“Failed”);

ftp_close($ftpId);

?>

ftp_chmod

It sets permissions on a file via FTP

Example

<?php

$fName=”test”;

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

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

ftp_chmod($ftpId, 0777,$fName or die(“Failed”);;

?>

ftp_chdir

It changes the current directory on a FTP server

Example

<?php

$fName = “/home/user/test.txt”;

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

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

ftp_chdir($ftpId, ‘phpcodez’);

?>

ftp_cdup

It changes to the parent directory

Example

<?php

$fName = “/home/user/test.txt”;

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

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

ftp_chdir($ftpId, ‘phpcodez’);

ftp_cdup($ftpId) or die(“Failed”);

  echo ftp_pwd($ftpId);

?>

ftp_alloc

It allocates space for a file to be uploaded

Example

<?php

$fName = “/home/user/test.txt”;

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

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

ftp_alloc($ftpId, filesize($fName), $result) or die($result);

ftp_put($ftpId, ‘temfileName’, $file, FTP_BINARY);

ftp_close($ftpId);

?>

FTP functions

  • ftp_alloc – It allocates space for a file to be uploaded
  • ftp_cdup – It changes to the parent directory
  • ftp_chdir – It changes the current directory on a FTP server
  • ftp_chmod – It sets permissions on a file via FTP
  • ftp_close – It closes an FTP connection
  • ftp_connect – It opens an FTP connection
  • ftp_delete – It deletes a file on the FTP server
  • ftp_exec – It requests execution of a command on the FTP server
  • ftp_fget – It downloads a file from the FTP server and saves to an open file
  • ftp_fput – It uploads from an open file to the FTP server
  • ftp_get_option -It retrieves various runtime behaviours of the current FTP stream
  • ftp_get – It downloads a file from the FTP server
  • ftp_login – It can be used to log in to an FTP connection
  • ftp_mdtm – It returns the last modified time of the given file
  • ftp_mkdir – It creates a directory on the FTP server
  • ftp_nb_continue – Continues retrieving/sending a file
  • ftp_nb_fget – It retrieves a file from the FTP server and writes it to an open file
  • ftp_nb_fput – It stores a file from an open file to the FTP server
  • ftp_nb_get – It retrieves a file from the FTP server and writes it to a local file
  • ftp_nb_put – It stores a file on the FTP server
  • ftp_nlist – It returns a list of files in the given directory
  • ftp_pasv – It turns passive mode on or off
  • ftp_put – It uploads a file to the FTP server
  • ftp_pwd – It  returns the current directory name
  • ftp_quit – Its an alias ftp_close() and  closes ftp conection
  • ftp_raw – It sends an arbitrary command to an FTP server
  • ftp_rawlist – It returns a detailed list of files in the given directory
  • ftp_rename – It renames a file or a directory on the FTP server
  • ftp_rmdir – It removes a directory on the FTP server
  • ftp_set_option – It sets miscellaneous runtime FTP options
  • ftp_site – It sends a SITE command to the server
  • ftp_size – It returns the size of the given file
  • ftp_ssl_connect – It opens an Secure SSL-FTP connection
  • ftp_systype – It  returns the system type identifier of the remote FTP server