How can the PHP function "chmod" be used to set file permissions after uploading files?

After uploading files to a server using PHP, it is important to set appropriate file permissions to ensure security and access control. The PHP function "chmod" can be used to change the permissions of a file. This function takes two parameters: the file path and the desired permissions in octal format. For example, to set a file to be readable, writable, and executable by the owner, and readable by others, you would use "chmod('/path/to/file', 0755);".

$file_path = '/path/to/uploaded/file.txt';
// Set file permissions to be readable, writable, and executable by the owner, and readable by others
chmod($file_path, 0755);