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
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://webupload@86.131.190.81 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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

  • 5 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.