RE: [PHP] Updating (appending) a file
| From: | Martin Towell | Date: | Tue, 02 Jul 2002 04:27:50 +0000 |
| Subject: | RE: [PHP] Updating (appending) a file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-104830@lists.php.net to get a copy of this message | ||
if the php file is: mydomain.com/index.php
and the data file is: mydomain.com/files/Names.txt
then the relative path is not "\\files\\Names.txt" , it's
"files\\Names.txt"
HTH
Martin
-----Original Message-----
From: Chris Earle [mailto:chris@earleweb.com]
Sent: Tuesday, July 02, 2002 3:29 PM
To: php-general@lists.php.net
Subject: [PHP] Updating (appending) a file
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.");
}
}
---------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php