When anyone learning approaches the task of setting permissions on a media upload folder that is destined for public access they might instinctively think that it should be set to 777
or 666
due to all the incorrect tutorials that exist out in the wild.
So, today I decided that I wanted to understand the whole idea of setting correct/secure folder access permissions.
I discovered that on my Ubuntu 20.04 server I needed to assign 700
(or 770
if the owner is a real user) to allow uploads with move_uploaded_file()
.
Why does www-data
need execute
access to write
the file?
My best assumption is that because move_uploaded_file()
is a function of PHP it is essentially executing that function within the destination folder (even though the actual call to that function is in an entirely different folder/file location).
Since I'm never correct in my first assumptions, I decided to ask.