Re: I need a useful sample code for opening from ftp servers using fopen() or file() commands
| From: | nicos@php.net | Date: | Wed, 04 Sep 2002 01:11:33 +0000 |
| Subject: | Re: I need a useful sample code for opening from ftp servers using fopen() or file() commands | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115129@lists.php.net to get a copy of this message | ||
Hi,
You should read www.php.net/fopen :
If filename begins with "ftp://" (not case sensitive), an ftp
connection to
the specified server is opened and a pointer to the requested file is
returned. If the server does not support passive mode ftp, this will fail.
You can open files for either reading or writing via ftp (but not both
simultaneously). If the remote file already exists on the ftp server and you
attempt to open it for writing, this will fail. If you need to update
existing files over ftp, use ftp_connect().
You should also read www.php.net/feof, www.php.net/fread You can't echo the
var of fopen, you must use fread and verify you're not at the end of the
file with
while(!feof($fich))...
--
Nicos - CHAILLAN Nicolas
nicos@php.net
www.WorldAKT.com - Hébergement de sites Internet
"Javier Campo Martinez" <jcampom@electricaribe.com> a écrit dans le message
de news:
012e01c253ab$1669a310$5989f00a@costacaribe.com...
Hi,
I will appreciate if you have some sample code about opening a file from a
UNIX server.
This is the code I wrote for this issue:
<?php // test program
$conn_id=0;
$fich = fopen("ftp://usuario:clave@servidor/afiedt.buf","r");
while ($fich[$i]) {
echo $fich[$i];
echo "<br>";
$i++;
}
?>
This is the message error/warning:
Warning: File not found in d:\apache\htdocs\lee_fichero2.php3 on line 3
Warning: file("ftp://...@servidor/afiedt.buf") - No such file
or directory
in d:\apache\htdocs\lee_fichero2.php3 on line 3
In the other hand, my php version is 4.0
In the help of the command fopen(), it says:
If filename begins with "ftp://" (not case sensitive), an ftp
connection to
the specified server is opened and a pointer to the requested file is
returned. If the server does not support passive mode ftp, this will fail.
You can open files for either reading or writing via ftp (but not both
simultaneously).
phpinfo() returns me the following ftp topic:
FTP support enabled
I just don't know what more can I do ...
Thanx in advance
Javier