What is the best practice for setting chmod permissions after saving images in PHP?

After saving images in PHP, it is important to set appropriate chmod permissions to ensure that the files are secure and accessible as needed. The recommended best practice is to set the permissions to 0644 for files and 0755 for directories. This allows the owner to read and write the files, while also allowing others to read the files and execute the directories.

// Set chmod permissions for saved images
chmod($imageFilePath, 0644); // Set permissions for files
chmod($imageDirectoryPath, 0755); // Set permissions for directories