fileSetAccessMode

Sets the attributes of an on-disk file on UNIX or Linux. This function does not work with in-memory files.

fileSetAccessMode(filePath, mode) → returns void

fileSetAccessMode Argument Reference

filePath string
Required

Path to file

mode string
Required

Access mode (the same attributes you use for the Linux command 'chmod')

Each digit specifies who is granted the access:
* 1st digit: owner
* 2nd digit: group
* 3rd digit: other

Each number specifies which right is granted:
* 4: read (r)
* 2: write (w)
* 1: execute (e)

Let's assume that matrix as seen on linux systems: rwerwerwe. You can combine the numbers for read, write and exucute permissions to achieve combined permissions:
* 3: write & execute
* 5: read & execute
* 6: read & write
* 7: read, write and execute

For example, 400 specifies that only the owner can read the file; 004 specifies that anyone can read the file.
In rwe-notation 400 means r-------- and 004 ------r-- whereas 751 means rwer-er--.

Examples sample code invoking the fileSetAccessMode function

<cfscript> 
 fileSetAccessMode("test1.txt", "004"); 
 </cfscript>   

Fork me on GitHub