Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > writing to remote file via PHP

writing to remote file via PHP
Thread Tools
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Oct 20, 2003, 04:34 AM
 
OK, here's the deal:

I have to make a small data base [basically just a xml file]. I decided to make a custom interface to insert the data. So I used PHP.

The problem I have is that I can only append the existing file if I have set it "read/write" to everyone. But that's not a good idea. Someone can just erase it for "fun".

if I use say: fopen("ftp://myname:mypass@myserver/Users/myname/Sites/data.xml", "w")
then it only works if the file doesn't exist, that is, I can write one single file. Besides, I need to use "a" so...

How can I do this?

How can i write to a file on my server? yet have it writable only for one user.

HELP
     
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Oct 20, 2003, 09:23 AM
 
fopen does not do what you need You could use MySQL, but that may be overkill for your situation.
Travis Sanderson
     
VEGAN  (op)
Senior User
Join Date: Jun 2002
Location: UK
Status: Offline
Reply With Quote
Oct 20, 2003, 10:16 AM
 
Originally posted by redJag:
fopen does not do what you need You could use MySQL, but that may be overkill for your situation.
But they always have fopen/fput examples in the tutorials! It seems like such a small thing that i need... and can't have...

Can I change the user ID of the apache process, then? Coz the whole problem is that it runs as "nobody". If I could identify myself as "php" group or something, I'd feel more safe [allowing "write" to all in the group of "php"]

????
     
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 31, 2003, 03:49 PM
 
dunno if you've solved the problem or not, but how about this:
- write the XML file to a temporary local file.
- FTP the temporary file to your server, saving it as whatever it needs to be saved as.
- Delete the local file.
- Done

Let me know if you need any more advise on doing this. We do it all the time for product datafeeds (though server to server; but localhost to server should work just the same).
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2