RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1349 | Replies: 3
Reply
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation: mikeandike22 is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 17
Featured Blogger
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

opening files with read and write access

  #1  
Jul 26th, 2006
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.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2005
Posts: 732
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 6
Solved Threads: 44
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Master Poster

Re: opening files with read and write access

  #2  
Jul 26th, 2006
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.
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!
Reply With Quote  
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation: mikeandike22 is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 17
Featured Blogger
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: opening files with read and write access

  #3  
Jul 26th, 2006
thank you, unfortunately yea I am on windows at work so chmod wont work but no big deal.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote  
Join Date: Sep 2005
Posts: 732
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 6
Solved Threads: 44
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Master Poster

Re: opening files with read and write access

  #4  
Jul 27th, 2006
On windows try chmod 775 for non-writeable and 666 for writeable.
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!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 7:13 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC