Server to Server

Discussion in 'PHP' started by gigamike, Jul 26, 2007.

  1. #1
    Guys,

    I have 2 physical server, i was able to make a script that uploads the file using move_uploaded_file. Guys any idea on how i can transfer that uploaded file to another physical server using php.

    Thanks,

    Mike
     
    gigamike, Jul 26, 2007 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    jestep, Jul 26, 2007 IP
  3. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi Jestep,

    i try to test one using the FTP. Any ideas with this error

    Warning: ftp_login() [function.ftp-login]: You will be disconnected after 15 minutes of inactivity. in /home/adminga/public_html/videos_add_save.php on line 103

    102 $ftp_conn_id=ftp_connect($ftp_server);
    103 $login_result=ftp_login($ftp_conn_id, $ftp_user_name, $ftp_user_pass);

    Thanks,

    Mike

     
    gigamike, Jul 26, 2007 IP
  4. wmbetts

    wmbetts Peon

    Messages:
    27
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That error means you didn't do anything for 15 min and the server disconnected you.
     
    wmbetts, Jul 26, 2007 IP
  5. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #5
    I think it is just a response from the other server. The ftp service on the server you are connecting to can' distinguish between a php ftp connection or a dreamweaver ftp connection so it sends the same response.

    I would set your php error level at E_ERROR and not at E_WARNING. That warning is more for people using an FTP client to connect.

    At the top of the page you can just use this:
    error_reporting(E_ERROR);

    or

    error_reporting(0);

    if you don't want any errors.
     
    jestep, Jul 26, 2007 IP
  6. wmbetts

    wmbetts Peon

    Messages:
    27
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Umm no? Not to be an ass, but a ftp connection is an ftp connection no matter what starts it.

    Here's an example taken from php.net

    
    <?php
    // set up basic connection
    $conn_id = ftp_connect($ftp_server);
    
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    
    // check connection
    if ((!$conn_id) || (!$login_result)) {
            echo "FTP connection has failed!";
            echo "Attempted to connect to $ftp_server for user $ftp_user_name";
            exit;
        } else {
            echo "Connected to $ftp_server, for user $ftp_user_name";
        }
    
    // upload the file
    $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
    
    // check upload status
    if (!$upload) {
            echo "FTP upload has failed!";
        } else {
            echo "Uploaded $source_file to $ftp_server as $destination_file";
        }
    
    // close the FTP stream
    ftp_close($conn_id);
    ?> 
    
    Code (markup):
     
    wmbetts, Jul 27, 2007 IP
  7. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #7
    That's what I was implying but I mistyped the t after the can'.

     
    jestep, Jul 27, 2007 IP
  8. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Use sshfs with key based authentication. It makes the remote server look like a normal server.
     
    matthewrobertbell, Jul 28, 2007 IP