Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1349 | Replies: 3
![]() |
•
•
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation:
Rep Power: 7
Solved Threads: 17
I need to open an xml file and allow people to add entries to the file. So i need to open it with read and write access be able to insert an entry and then close it with read only access so another program (adobe bridge) cant write over the file.
Use chmod to set the permissions of the file so its writable. Then open it with write access, then after you write and close the file, use chmod again to change the permissions to read only.
eg:
[php]
@chmod ($configfile, 0755);
$xml_string = file_get_contents($filepath);
read_write_to_xml($xml_string);
if ($fp = fopen($filepath, 'w')) {
fwrite($fp, $xml_string, strlen($xml_str);
fclose($fp);
} else {
echo 'Cannto write to file';
}
@chmod ($configfile, 0744);
[/php]
Should do it. Unless you're on windows, then chmod wouldnt make any sense.
eg:
[php]
@chmod ($configfile, 0755);
$xml_string = file_get_contents($filepath);
read_write_to_xml($xml_string);
if ($fp = fopen($filepath, 'w')) {
fwrite($fp, $xml_string, strlen($xml_str);
fclose($fp);
} else {
echo 'Cannto write to file';
}
@chmod ($configfile, 0744);
[/php]
Should do it. Unless you're on windows, then chmod wouldnt make any sense.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation:
Rep Power: 7
Solved Threads: 17
thank you, unfortunately yea I am on windows at work so chmod wont work but no big deal.
On windows try chmod 775 for non-writeable and 666 for writeable.
see: http://www.php.net/manual/en/function.chmod.php
see: http://www.php.net/manual/en/function.chmod.php
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode