leedude Posted July 19, 2006 Share Posted July 19, 2006 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. Quote Link to comment Share on other sites More sharing options...
designationlocutus Posted July 19, 2006 Share Posted July 19, 2006 Do you have a username and password set for the FTP server? Quote Link to comment Share on other sites More sharing options...
leedude Posted July 19, 2006 Author Share Posted July 19, 2006 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. Quote Link to comment Share on other sites More sharing options...
leedude Posted July 21, 2006 Author Share Posted July 21, 2006 ok, ive tried the script with ftp.at.debian.org and other ftp sites. same result.Please help someone. the --ftp-enable option is on in my php configure command by the way. Quote Link to comment Share on other sites More sharing options...
designationlocutus Posted July 24, 2006 Share Posted July 24, 2006 Try it with your passwords and see what happens. Quote Link to comment Share on other sites More sharing options...
leedude Posted July 24, 2006 Author Share Posted July 24, 2006 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? Quote Link to comment Share on other sites More sharing options...
designationlocutus Posted July 25, 2006 Share Posted July 25, 2006 Try and add passive mode to your script and see if the result changes (place it after the ftp_login function)[code]<?phpftp_pasv($conn_id, true);?>[/code] Quote Link to comment Share on other sites More sharing options...
leedude Posted July 26, 2006 Author Share Posted July 26, 2006 Nope, no effect. It seems that the problem is with ftp_connect. Quote Link to comment Share on other sites More sharing options...
myron Posted December 28, 2006 Share Posted December 28, 2006 Did you ever find a solution to your ftp_connect problem? If so, what was it? I'm having the same problem.Myron Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.