Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP - writing to a file

Status
Not open for further replies.

kaasu

Programmer
Joined
Oct 6, 2003
Messages
2
Location
US
Hello, I am a PHP newbie and I have created a script to write some text to a file. It has been giving me this error

Warning: fopen(./category.xml): failed to open stream: Permission denied in c:\inetpub\ on line 16
Cannot open file

Here is the code example

$myfilename = "./category.xml";
if (!($fp=fopen("$myfilename","w"))) die("Cannot open file");
if(!(fwrite($fp,"Hello world"))) die("Error in writing");
fclose($fp);

Any help is appreciated
 
You want to make sure that the user as which the web server runs has write privileges in the area where you write the file. This is more related to the OS and the permissions settings than to PHP.
Tell us which evrsion of Win you use.
 
I am using windows XP. I have also tested it on a unix server (my actual production server) and it still gives me the same error. Do I have to give some specific permission in unix (I am quite a newbie to unix as well). The file is located in the same folder as the calling template. Do I have to make some changes to php.ini file for writing permission on unix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top