How To Upload A File To Cpanel From Another Server/URL?

Question

I am manually migrating my website (WordPress) over to another cPanel account, and my internet connection isn’t overly fast. I have compressed my files and created an archive in a .zip file. Instead of downloading the .zip file to my home computer and re-uploading it to the new Cpanel server, how can I simply transfer the files across server-to-server?

Answer

Downloading your files to your computer and re-uploading them can be a bit of a pain and a time waster, especially when you have a slow internet connection. Transferring files server-to-server is a much better option.

Depending on your web hosting provider, you might be able to use a PHP Function called WGET.

Here’s a script which you can upload to your webserver, enter the URL of the file you want to transfer and hit Upload. The file will start transferring across in the location of the script.

Once you are done, make sure you remove the script, as you do not want hackers uploading malicious files to your webserver!

<!DOCTYPE html>
<html>
<head>
    <title>Upload file from URL</title>
</head>
<body>
<?php
    $BASE_URL = strtok($_SERVER['REQUEST_URI'],'?');

    if (isset($_POST['url'])){
        $url = $_POST['url'];
        echo "Transferring file: {$url}<br>";
        exec("wget {$url}");
    }
?>
    <form name='upload' method='post' action="<?php echo $BASE_URL; ?>">
        <input type='text' id='url' name='url' size='128' /><br>
        <input type="submit" value="Upload">
    </form>
</body>
</html>

Comments

  1. By megha

    Reply

  2. Reply

  3. By Hazael Diaz

    Reply

Leave a Reply