'Is there any way to upload file directly from URL in filemanager of cPanel

This might be a very common question but i searched lot and finally decided to get some expert advice.

I was wondering if someone have uploaded file directly from URL to cPanel file manager. I can upload file from my computer using upload tab in file manager but not able to find any option for extracting data from URL.

I have tried several forums, Q/A websites but got nothing. I will really appreciate if someone can brought this question on to expert's attention.

I have looked

http://forums.cpanel.net/f145/filemanager-upload-url-215911.html

http://forums.cpanel.net/f5/upload-via-url-305691.html

and my other places but found nothing but the question.



Solution 1:[1]

I too had this question. Being on a slow connection downloading and then uploading again wasn't an option for me.

There isn't any way to do this through the cPanel filemanager at present. If you don't have access to SSH you can get around it like this:

  1. Create a new file in the filemanager, call it get1.php or whatever and place it in a location you will be able to access on your domain.
  2. In get.php edit the file in the filemanager, and put this code: <?php exec("wget http://domain.com/path-to-file.zip"); ?>

  3. Now navigate to your file you created in step 1 in your browser, so it might be http://domain.com/get1.php

  4. Wait. The page might return a 500 error, thats OK, the wget command should still go through.
  5. In cPanel in your file manager reload the directory where you put get1.php, you will see the file there waiting for you. Done.

Now of course this is highly insecure as any bot or person could just request your get1.php file, so make sure you delete it after your done. This is just a simple hack, any better ideas appreciated.

Solution 2:[2]

I had the same issue. I couldn't upload some big files which I needed to transfer from one server to another. Both FTP and cPanel File Manager kept failing. I created an upload.php file (extending the solution offered above) and copied it to the destination directory. I couldn't believe how quickly this technique works! It literally took seconds for 50MB files. Here are the contents of my php file:

<!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>

After I finish transferring my files, I always remove this php file from the server, so as not to give potential hackers an easy way to replace files on my server. Please do not forget this important step!

Solution 3:[3]

Used script and instructions from PHP Url File Remote Uploader No Size Limit and with some changes for more security,

here is the end result:

remote upload

Instructions:

  1. Create a directory and paste code below in file named index.php
  2. In the created directory create another directory named files and its change permission to 766 (this prevents hackers from uploading php files and potentially hacking you, you can still access the file from cpanel but you cant download it from your browser, if you want to download it from browser change permission to 777 but remember to change it back or delete the file)
  3. Enjoy
<title>Remote Upload</title>
<center>

</br</p></br</p><form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>

<b>Instruction:</b>
</p>Sample values for ftp and http
</p>ftp://username:[email protected]/path/to/file.png
</p>ftp://example.com/path/to/file.png
</p>http://www.example.com/path/to/file.png

<?php

// maximum execution time in seconds
set_time_limit (24 * 60 * 60);

if (!isset($_POST['submit'])) die();

// folder to save downloaded files to. must end with slash
$destination_folder = 'files/';

$url = $_POST['url'];
$newfname = $destination_folder . basename($url);

$file = fopen ($url, "rb");
if ($file) {
  $newf = fopen ($newfname, "wb");

  if ($newf)
  while(!feof($file)) {
    fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
  }
}

if ($file) {
  fclose($file);
}

if ($newf) {
  fclose($newf);
}

?>
</center>

Solution 4:[4]

Create a new .php file in your directory and paste the code below in it.

after running the script, it uploads in a file named test.zip

<?php
copy("YOUR_URL", "test.zip");
?>

Solution 5:[5]

Well Yes OfCourse There Is A Way

U Can Use "wget" in your ssh console

just open your ssh console type in wget command: for eg : wget ;

and you are done

Solution 6:[6]

You can use RapidLeech. It's a CMS to "Transload" files (server-to-server) instead of uploading. But the Hosts usually ban you for using RL, because it consumes too much resources. But it has really cool functions. You can get Youtube videos directly with any screen size you want, and also you can transload your files back to famous file uploading websites such as 4shared by providing your account info.

Solution 7:[7]

Best Way

This Worked For Large Files

  1. First create a file on the public_html "get.php"

  2. Copy blow code and save

  3. Replace YOUR_URL with your URL

  4. Open the sitename.com/get.php

  5. Enjoy :)

code:

<?PHP
    ini_set('max_execution_time', '0');
    define('BUFSIZ', 4095);
    $url = 'YOUR_URL'; 
    $rfile = fopen($url, 'r');
    $lfile = fopen(basename($url), 'w');
    while(!feof($rfile))
    fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
    fclose($rfile);
    fclose($lfile);
    ?>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BlissOfBeing
Solution 2 Eyal Azulay
Solution 3
Solution 4 Ali momen doost
Solution 5 user2984602
Solution 6 Amin Darvand
Solution 7 hossein naghneh