1

Heys Guys! I'm trying to create a new xml file with php on my ubuntu server. The code looks like

$myfile = fopen("test.xml", "w") or die ("Unable to write file");
fwrite($myfile, "Test");
fclose($myfile);

But whenever this php file is called I get "Unable to write file". Does anybody know what the issue is and how to fix it? Thanks

1 Answer 1

2

In the Linux server, it may be a file permission issue try this command below in your directory. I am assuming your directory is /var/www/html if not replace this with your directory path and run commands.

chown -R www-data:www-data /var/www/html

chmod -R 755 /var/www/html

Sign up to request clarification or add additional context in comments.

1 Comment

chown -R www-data:www-data /var/www/html solved the problem, thanks a lot :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.