w3resource

PHP: ftp_chmod() function

Description

The ftp_chmod() function is used to set permissions on a specified remote file via FTP.

Version:

(PHP 5 )

Syntax:

ftp_chmod(ftp_connection, imode, filename) 

Parameters:

Name Description Required /
Optional
Type
ftp_connection The link identifier of the FTP connection. Required Resource
imode The new permissions, specified as an octal value. Required Integer
filename The remote file name. Required String

Return value:

New file permissions on success or FALSE on error.

Value Type: Integer.

Example:

<?php
$ftp_server="192.168.0.2";
$ftp_user_name="abc123";
$ftp_user_pass="abc123";
$file = 'D:/datasoft/test/test.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to chmod $file to 644
if (ftp_chmod($conn_id, 0755, $file) !== false) {
 echo "$file chmoded successfully to 755\n";
} else {
 echo "could not chmod $file\n";
}
// close the connection
ftp_close($conn_id);
?>

See also

PHP Function Reference

Previous: ftp_chdir
Next: ftp_close



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/ftp_chmod.php