What potential solutions have been tried, such as chmod and chown, and what were the results?

The issue is likely related to file permissions, where the PHP script does not have the necessary permissions to read or write to a file. One potential solution is to use the chmod function in PHP to change the file permissions, or the chown function to change the file owner.

// Change file permissions using chmod
$file = 'example.txt';
$permissions = 0644; // set the desired permissions
if (file_exists($file)) {
    chmod($file, $permissions);
    echo 'File permissions changed successfully';
} else {
    echo 'File does not exist';
}

// Change file owner using chown
$file = 'example.txt';
$user = 'www-data'; // set the desired owner
if (file_exists($file)) {
    chown($file, $user);
    echo 'File owner changed successfully';
} else {
    echo 'File does not exist';
}