/    Sign up×
Community /Pin to ProfileBookmark

file on server #1 copy onto server #2 via upload (because it doesn’t support PHP)

I have two servers. One is a free website that doesn’t support PHP and the other is my personal server that supports PHP.
I want to be able to transfer a file from server #1 onto server #2 (the free server that doesn’t support PHP).
Since server #2, the free server, doesn’t support PHP, I can’t simply setup a PHP program on that side to accept an HTTP request and mange files.
I need some way for PHP on my personal server to be able to actually access the second server’s FTP via a socket or some such and send the file.

To draw a scenario, let’s say the file on my personal server is called “fileupload232.jpg” and exists in the root directory. How would I now copy the file so it exists on both servers in their root directorys?

Why do I care about my free server if I already have a better server, you might ask. Because my friend only has a free server and would like an Admin CP build for it but it don’t support PHP so the Admin CP will need to move to my server.

Side note:
My personal server’s PHP version is quite low…
<? echo phpversion(); ?> outputs [color=blue]4.3.10[/color]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterauthorDec 22.2005 — After a lot of searching, I'm thinking about using one or both of the following two methods but have no idea how to combine them and/or send files...
[list]
  • [*]ftp_connect

  • [*]ftp_login

  • [/list]


    [b]edit:[/b]

    I think I found the answer:
    [code=php]
    <?php

    // setup $host and $file variables for your setup before here...

    $hostip = gethostbyname($host);
    $conn_id = ftp_connect($hostip);

    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

    // IMPORTANT!!! turn passive mode on
    ftp_pasv ( $conn_id, true );

    if ((!$conn_id) || (!$login_result)) {
    echo "FTP connection has failed!";
    echo "Attempted to connect to $host for user $ftp_user_name";
    die;
    } else {
    echo "Connected to $host, for user $ftp_user_name<br>";
    echo "Host IP is $hostip<br>";

    // upload a file
    if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
    echo "successfully uploaded $file<br>";
    } else {
    echo "There was a problem while uploading $file<br>";
    }

    // close the connection
    ftp_close($conn_id);
    }
    ?>
    [/code]
    ×

    Success!

    Help @Ultimater spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...