burritobot Posted February 7, 2008 Share Posted February 7, 2008 Below is some php code for simply printing the array of filenames within the folder "images" at a certain FTP address. The code works just fine if I use it within the same domain. (i.e. I execute the script on my mediatemple server, and define the FTP info as an FTP account within the same domain). However, when I run the script on my mediatemple account, and define the FTP info on a different domain (a different mediatemple-hosted FTP site, different domain), it does nothing, then times out after 90 seconds. Can anybody tell me what I'm doing wrong? <?php $ftp_server=<IP address>; $ftp_user_name =<username>; $ftp_user_pass =<password>; // set up basic connection $conn = ftp_connect($ftp_server) or die("Could not connect"); if(ftp_login($conn,$ftp_user_name,$ftp_user_pass)){ echo("connected<br>"); //this works no matter what echo ftp_systype($conn); //this also works print_r(ftp_nlist($conn,"images")); //this makes it hang and timeout after 90 secs }; ftp_close($conn); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89850-solved-some-php-ftp-commands-wont-execute-across-domains/ Share on other sites More sharing options...
btherl Posted February 7, 2008 Share Posted February 7, 2008 Try adding a timeout to ftp_connect(), and see what happens. It sounds as if your host may not allow ftp connections to the outside. If that's the case, they may still allow it via a proxy server. Quote Link to comment https://forums.phpfreaks.com/topic/89850-solved-some-php-ftp-commands-wont-execute-across-domains/#findComment-460568 Share on other sites More sharing options...
burritobot Posted February 7, 2008 Author Share Posted February 7, 2008 The thing is, the code in lines 9 and 10 work fine, which means it is actually connecting to the remote server. However, when I uncomment line 11 (using the ftp_nlist() method), thats when it times outs. It also times out when i try to execute other FTP methods, like ftp_get() or ftp_put(). I've changed permissions on both my server and remote server to no avail. However, I still suspect you may be right about my host not accepting certain ftp methods from the outside. I tried adding the timeout to the ftp_connect() and it's doing the same thing, just after 5 seconds, instead of 90. Can you point me in the right direction on how to try this using the proxy server? Myabe that will help. Thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/89850-solved-some-php-ftp-commands-wont-execute-across-domains/#findComment-460756 Share on other sites More sharing options...
burritobot Posted February 7, 2008 Author Share Posted February 7, 2008 Problem solved. All I had to do was connect using passive mode. Quote Link to comment https://forums.phpfreaks.com/topic/89850-solved-some-php-ftp-commands-wont-execute-across-domains/#findComment-460856 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.