How can PHP developers avoid the problem of files being owned by the wrong user/group after uploading?

When uploading files using PHP, developers can avoid the problem of files being owned by the wrong user/group by setting the correct permissions on the uploaded files. This can be achieved by using the `chmod()` function in PHP to set the desired permissions after the file has been uploaded.

// Upload file
$targetDir = "uploads/";
$targetFile = $targetDir . basename($_FILES["file"]["name"]);
move_uploaded_file($_FILES["file"]["tmp_name"], $targetFile);

// Set correct permissions
chmod($targetFile, 0644);