Hi all,
i have a problem in opening a xml file using fopen.
I get an error called
++++++++++++++++++
Warning: fopen(abc.xml): failed to open stream: Permission denied in c:\inetpub\wwwroot\myphp\fopentest.php on line 6
++++++++++++++++++

My xml file name is abc.xml
& the contents in th sml file is
+++++++++++++++++++++
<?xml version="1.0" encoding="ISO-8859-1"?>

<books>
<book>
<author>AA</author>
<title>Sayings of the Century</title>
<price>8.95</price>
</book>
</books>
+++++++++++++++++++

My php file is
++++++++++++++++++++
$filename = "abc.xml";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
echo $contents;
fclose ($handle);
++++++++++++++++

all the files are inthe same location..
Infact i'm able to opne a text or php file using the same php code?
Also i had uncommented the line
"extension=php_domxml.dll" in php.ini also & restarted the webserver.
I'm using IIS

can u tell me what is the problem??

Thanks
Thumuluru

    I know you say that you were able to read other files with the same code, however, have you checked that you have access to read the abc.xml file?

    I don't know on Windows, but the error is clearly a file access permission problem. Just double check that the XML file has correct (read) permissions set.

      yes it does have all the necessary permisions.
      i had given full control, read,write, execute.. all

      ??

        Just as a test and to try and debug this problem, change the extension of your filename from 'xml' to lets say 'txt'. Don't forget to change your php script to read 'abc.txt'.

        Just make sure the php script, the directory, and file have the correct permissions. I have a feeling that it's a server setting that needs to change.

          Changig the extension also gives the same error๐Ÿ™

          ?? is the problem..

            I think someone else needs to help you because I'm not familiar with IIs.

            I think the IIs configuration file may need changing on the Windows platform to work better with your PHP installation.

            Look into who owns the file and is able to change or read the file(s).

            Look into PHP chown() function:
            http://us4.php.net/manual/en/function.chown.php

            Have you searched this forum. Here are others to search:

            http://codewalkers.com/forum/index.php

            http://www.phpfreaks.com/forums/

            Good Luck

              Hi toplay,
              i feel php handles the open of xml files differently from other formats(txt files).
              If the permission or ownership is the real problem, the same script wudn't open txt or php files.
              how ever i will check it up the sites uhave mentioned.
              thanks a ton for the info..
              thumuluru

                Write a Reply...