Discussion:
ftp_get, ftp_put problem
Antonis Varkas
2006-01-20 13:26:23 UTC
Permalink
Hi,

I am writing a php script to upload/download a file onto/from an FTP
Server. I manage to connect to the server, login correctly, change
directory, list all the files there but fail to get or put the file.
The documentation says that ftp_get and ftp_put return TRUE or FALSE. In
my case nothing at all is returned.

Using the following code part, the $test variable is empty

// upload the file
$test = ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY);
if ($test) {
echo "Successfully uploaded $local_file.\n";
} else {
echo "There was a problem while uploading $local_file.\n";
echo("TEST: ".$test."\n<br/>");
}
I don't get any warnings.
Does this indicate something I can't figure out ?

Thanks in advance
A.Varkas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jay Blanchard
2006-01-20 14:17:07 UTC
Permalink
[snip]
I am writing a php script to upload/download a file onto/from an FTP
Server. I manage to connect to the server, login correctly, change
directory, list all the files there but fail to get or put the file.
The documentation says that ftp_get and ftp_put return TRUE or FALSE. In
my case nothing at all is returned.

Using the following code part, the $test variable is empty

// upload the file
$test = ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY);
if ($test) {
echo "Successfully uploaded $local_file.\n";
} else {
echo "There was a problem while uploading $local_file.\n";
echo("TEST: ".$test."\n<br/>");
}
I don't get any warnings.
Does this indicate something I can't figure out ?
[/snip]

You may have to set the passive mode, see
http://us2.php.net/manual/en/function.ftp-pasv.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Richard Davey
2006-01-20 14:19:23 UTC
Permalink
Post by Antonis Varkas
I am writing a php script to upload/download a file onto/from an
FTP Server. I manage to connect to the server, login correctly,
change directory, list all the files there but fail to get or put
the file.
The documentation says that ftp_get and ftp_put return TRUE or
FALSE. In my case nothing at all is returned.
Do you have access to the FTP server log files? They would show you
exactly which stage it died at. My guess would be this is a PASV/port
issue.

Cheers,

Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Richard Lynch
2006-01-20 21:41:46 UTC
Permalink
Post by Antonis Varkas
I am writing a php script to upload/download a file onto/from an FTP
Server. I manage to connect to the server, login correctly, change
directory, list all the files there but fail to get or put the file.
The documentation says that ftp_get and ftp_put return TRUE or FALSE. In
my case nothing at all is returned.
Using the following code part, the $test variable is empty
// upload the file
$test = ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY);
if ($test) {
echo "Successfully uploaded $local_file.\n";
} else {
echo "There was a problem while uploading $local_file.\n";
echo("TEST: ".$test."\n<br/>");
}
I don't get any warnings.
Does this indicate something I can't figure out ?
FTP active/passive setting changes whether FTP tries to open up a
second connection back to your computer to put/get the actual file
contents, leaving the original connection for you to send more
commands etc.

If your firewall doesn't allow that second connection to happen, then
you may encounter this phenomenon.

Try switching active/passive around and see what you get.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...