Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress Plugin

I’m trying to write to an XML file in a WordPress Plugin. I’m on my local machine, a Mac running MAMP. I have PHP 5.2.13 My code is:

$file_handle = fopen('markers.xml', 'w');
$stringdata = "Test Info";
fwrite($file_handle, $stringdata);
fclose($file_handle);

I get the following error:

Read More

Warning: fopen(markers.xml) [function.fopen]: failed to open stream:
Permission denied in
/Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php
on line 73

Warning: fwrite(): supplied argument is not a valid stream resource in
/Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php
on line 75

Warning: fclose(): supplied argument is not a valid stream resource in
/Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php
on line 76

markers.xml has permissions set to 777.

Any suggestions on how to solve this problem?

Thank you.

Related posts

Leave a Reply

1 comment