What I want to do is very simple, I have a txt file on a ftp server,
that contains the number of visits to my site. I manage to open the file
with "fopen($filename,"r+"), but the information is not written to the
file. I know that on a ftp server one can only open a file with fopen for
read OR write, so I have changed the fOpen to "fopen($filename,"a") or
fopen($filename,"w") . This does not work as I am getting a warning
message that the file already exist and fopen fails. My ISP did not
compile PHP with FTP enabled, so I can not use an FTP session to delete the file
before attempting to write to the file. Is there any other way of deleting
the file, without using an FTP session. Below is an extract from my code,
if it will help:
<?
$sFileName = "ftp://myuser:[EMAIL PROTECTED]/folder/Counter.txt"; ....
$sOutput = "12345"
....
$file = fopen ($sFileName, 'r+'); if (!$file) { echo "<p>Unable to open hitcounter file - File is temporary unavailable\n"; return $result; } $written = fwrite($file,
$sOutput);
if ($written <= 0) { echo "<p>Unable to write hitcounter, file is temporary unavailable\n"; fclose($file); return $result; } fclose($file); ?>
With mode = r+, I get a $written as 22, but it is not written to the
file
With mode = a or w, fopen fails.
I have been trying to get this resolved for some time now and can not get
it to work. I am a novice PHP writer, please help!
|
- [PHP] Re: fOpen in append mode on a FTP Server Elna Moorhouse
- [PHP] Re: fOpen in append mode on a FTP Server Elna Moorhouse