Search code examples
phpfilepermissionsumask

Odd permissions on uploaded files, lamp server


I'm getting odd permissions on files uploaded by php. I've captured the permissions using fileperms() before and after the move_uploaded_file() call and chmod() call. The permissions are 33152 before and 334232 after. I don't even know what these mean. I'm expecting like 0664 or something. For info: these numbers in hex and oct:

Dec: 33152 = 0x8180 and o100600, after I chmod(filename, 664) fileperms() gives: Dec: 33432 = 0x8298 and o101230

Super weird permissions. Note the first permissions are coming from the file in the tmp directory before I've moved it. The file name is something like /tmp/phpc9lNXw

Has anyone ever seen permissions like this on uploaded files? Where do they come from?


Solution

  • You are not saving the permissions in octal notation which is required -- To do this you need a leading zero in front of your permissions set ..

    chmod(filename, 0664)