What permissions should be set for directories where files are uploaded in PHP?
When files are uploaded in PHP, it is important to set the correct permissions for the directories where the files are stored. The recommended permissions for directories where files are uploaded in PHP are typically 755 or 775. This ensures that the directory is writable by the PHP script, but not publicly accessible for security reasons.
// Set the correct permissions for the directory where files are uploaded
$directory = 'uploads/';
if (!file_exists($directory)) {
mkdir($directory, 0755, true);
}