Updating (appending) a file
| From: | Chris Earle | Date: | Tue, 02 Jul 2002 05:28:47 +0000 |
| Subject: | Updating (appending) a file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-104829@lists.php.net to get a copy of this message | ||
I cannot figure out how to access the file and update it (which is just
/files/*.txt from where I'll be accesing it -- in other words I'm accessing
it from mydomain.com/index.php, but the file is
mydomain.com/files/Names.txt). By update I mean append. I tried to access
it with the complete local address (C:\\... it's a IIS5 server on Win2k; I
did use the \\).
So, what file path do I use to update (append) a file on the same Windows 2k
server as my web server (/files/*.txt is the location of the file relative
to the PHP code being executed).
I want to be able to update the file on my server (which can be accessed
through FTP the way $Location works out, if I do it manually in the
browser). My question is how do I go about accessing it? Do I have to use
the ftp_connect(); functions somehow or can I just go about with something
like this:
---------------------------------------------------
// This doesn't work though:
$Location = "ftp://". $Find->USER .":".
$Find->PASS ."@mysite.com/files/".
$Find->BRANCH .".txt";
if (!$fp = fopen($Location, "a"))
{ // This is always what shows
Error("Error: 0001. File (". $Location .") could not be found.");
}
else
{
if (!fwrite($fp, $Find->Line)) // line is an HTML tag/link (Something
like "<A HREF="http://somesite.com"
ALT="blah">")
{
Error("Error: 0002. Information was not written.");
}
if (!fclose($fp))
{
Error("Error: 0003. File close error.");
}
}
---------------------------------------------