What chmod 777 means
777 (rwxrwxrwx) gives every user on the system full control: anyone can modify the file or add and delete files in the directory.
It's often suggested as a quick fix for "permission denied" errors, but it hides the real problem (wrong owner or group) and opens a serious security hole,
especially on shared hosting or servers running web applications.
Instead, give ownership to the user that needs to write (chown www-data:www-data dir) and use 755/775 for directories and 644/664 for files.
For shared scratch directories, use 1777, which adds the sticky bit so people can only delete their own files.
Adjust the checkboxes above to see how a different mode compares, or go back to the chmod calculator.