I ran into an issue today with files uploaded through the WordPress Backend not getting the correct permissions. The permission on the new 2018 folder in the uploads directory as well as the files within it were too tight, the webserver user couldn’t even access them. I found the constants FS_CHMOD_DIR
and FS_CHMOD_FILE
that can be used to overwrite the default permissions for uploaded files. The WordPress Codex suggests using the the following settings in the wp-config.php
:
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) );
However, I haven’t been able to find documentation on the syntax of those constants. The octal notation of the permissions is clear, but what is up with the ampersand, the swung dash and the umask command without a parameter? This article by wpbeginner mentions those constants as well, however it only mentions defining the constants with the octal values alone. What’s the difference between that and the longer command above?