YouTip LogoYouTip

Func Ftp Chmod

body { font-family: Arial, sans-serif; line-height: 1.6; margin: 0; padding: 0; background-color: #f4f4f4; } .container { max-width: 1200px; margin: 0 auto; padding: 20px; background: #fff; } h1 { color: #333; border-bottom: 2px solid #007bff; padding-bottom: 10px; } h2 { color: #0056b3; margin-top: 30px; } table { width: 100%; border-collapse: collapse; margin: 20px 0; } th, td { border: 1px solid #ddd; padding: 12px; text-align: left; } th { background-color: #f2f2f2; } pre { background: #f8f9fa; padding: 15px; border-radius: 5px; overflow-x: auto; } code { font-family: 'Courier New', Courier, monospace; } .note { background: #e7f3ff; border-left: 4px solid #007bff; padding: 10px; margin: 20px 0; } .nav { background: #333; color: white; padding: 10px; } .nav a { color: white; text-decoration: none; margin-right: 15px; } .nav a:hover { text-decoration: underline; } .footer { margin-top: 40px; padding: 20px; background: #f4f4f4; text-align: center; font-size: 0.9em; color: #666; }

PHP ftp_chmod() Function

Complete PHP FTP Reference:

Definition and Usage

The ftp_chmod() function sets permissions for a file on the FTP server.

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

Syntax

ftp_chmod(ftp_connection, mode, file)

Parameters

Parameter Description
ftp_connection Required. Specifies the FTP connection to use.
mode Required. Specifies the new permissions. The mode parameter consists of 4 digits:
* The first digit is usually 0
* The second digit specifies permissions for the owner
* The third digit specifies permissions for the owner's group
* The fourth digit specifies permissions for everyone else
Possible values (sum the numbers below if you need to set multiple permissions):
* 1 = execute permission
* 2 = write permission
* 4 = read permission
file Required. Specifies the name of the file to change permissions for.

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);

?>

Complete PHP FTP Reference:

← Func Ftp CloseDom Obj Tablerow β†’