A: 

Use $perms &= 0511 instead of $perms &= 511. Permission masks are in octal notation, and the preceding 0 will make PHP interpret the number as octal.

Sjoerd
As I already explained, the print statement shows the correct permissions, which leads me to doubt the problem is being caused at this point.Changing this line causes the print statement to display incorrect permissions and does not fix the problem (permissions of uploaded files are still incorrect).
AllenJB
+1  A: 

Pass $perms to ftp_chmod, not $permsm.

Sjoerd
Thanks. That appears to make the code work as expected (I probably should've seen that, but I've been spending so long trying to make this code work I've lost sight through all the modifications I made).I still don't fully understand why $permsm doesn't work tho - it seems to be a typing issue, but no amount of decoct/octdec cycles or prepending '0's seemed to be resolving the issue.
AllenJB
Say the permission is rw-r--r--, or 644. $perms now contains the octal number 0644, which is 420 decimal. $permsm contains "0644", which is not interpreted as octal but as the decimal number 644, while you want 420.
Sjoerd