WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP ftp_chmod () function


Definition and usage

ftp_chmod () Function sets the permissions of the specified file on the FTP server.

If successful, the function returns the new permissions. If it fails, FALSE and a warning are returned.

Syntax

ftp_chmod (ftp_connection, mode, file)

parameters description
ftp_connection Required. Specifies the FTP connection to use.
mode Required. Define new permissions. The

mode parameter consists of 4 numbers:

  • The first number is usually 0
  • The second number specifies the permissions of the owner
  • The third number specifies the permissions of the user group to which the owner belongs
  • The fourth number specifies the permissions of everyone else

Possible values ​​(to set multiple permissions, total the numbers below):

  • 1 = execute permissions
  • 2 = write permission
  • 4 = read permissions
file Required. Specifies the name of the file whose permissions are to be modified.


Example

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"user","pass");

//Read and write for owner, nothing for everybody else
ftp_chmod($conn,"0600","test.txt");

//Read and write for owner, read for everybody else
ftp_chmod($conn,"0644","test.txt");

//Everything for owner, read and execute for everybody else
ftp_chmod($conn,"0755","test.txt");

//Everything for owner, read for owner's group
ftp_chmod($conn,"0740","test.txt");

ftp_close($conn);
?>