Jump to content

[SOLVED] Some PHP FTP commands won't execute across domains.


Recommended Posts

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);

?>

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.

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.