WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Usage of fopen/fwrite/fclose in WordPress theme (2 posts)

  1. dreamingof8a
    Member
    Posted 4 years ago #

    Hi everybody,

    I'm trying to create a file by using the following code in my sidebar.php:

    $file = fopen("file.xml", "w");
    fwrite($file, $xml);
    fclose($file);

    I tested the script outside WordPress and it works fine, however, when using it within WP I get an error message saying

    Warning: fopen(file.xml) [function.fopen]: failed to open stream: Permission denied in sidebar.php on line 46

    Warning: fwrite(): supplied argument is not a valid stream resource in sidebar.php on line 47

    Warning: fclose(): supplied argument is not a valid stream resource in sidebar.php on line 48

    Any idea what's wrong? the file exists already and has CHMOD 777 and as I stated before the script works fine when used stand alone.

    Cheers
    Felix

  2. dreamingof8a
    Member
    Posted 4 years ago #

    for some reason it works now ...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags