Jump to content

PHP FTP connection problems


leedude

Recommended Posts

I'm a sort of php newbie(at least i think so) and i am trying to connect to my ftp server which is on the same computer as my web server(Fedora Core 5 with MYSQL Server, Pure-ftpd, Apache 2 and PHP 5). I have just finished learning what i need to about sql and php, so now i moving onto ftp. I have started with a simple script to connect to the ftp server, but it just returns the error message.
[code]
<?php
$ftp_server = "localhost";
$conn_id = ftp_connect($ftp_server,21) or die("Couldn't connect to $ftp_server");
?>[/code]

Why is this happening? i can access the ftp server by conventional means (eg:typing "ftp localhost" at the linux command line or accessing it through an internet browser).
I have tried refering to the ftp server in different ways, like as 192.168.0.7(network ip address) or 86.131.190.81(internet ip).
Any help would be much appreciated.
Link to comment
https://forums.phpfreaks.com/topic/15028-php-ftp-connection-problems/
Share on other sites

Yes, i have several, but it is set up in such a way that anonymous access works aswell eg:

ftp://86.131.190.81 goes to the anonymous account( a linux mirror)
ftp://[email protected] goes to the account for upload to my web server.

Anyway, i thought the username and password details were only needed in the ftp_logon thing.
ok, ive done a login with the username and password. Same result.

[code]<?php
$ftp_server = "192.168.0.7";
$ftp_user_name = "username";
$ftp_user_pass = "password";
$conn_id = ftp_connect($ftp_server) or die("ERROR 1");
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("ERROR 2");
?>[/code]

This produces an ERROR 1(with the connection)
It seems that there is some kind of problem between my ftp program, and my php program.
is there any kind of apache or php.ini setting that would fix this?
  • 5 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.