Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 623
Shiva Avatar asked Apr 02 '14 21:04

Shiva


3 Answers

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.

like image 195
BlissOfBeing Avatar answered Oct 21 '22 15:10

BlissOfBeing


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!

like image 44
Eyal Azulay Avatar answered Oct 21 '22 15:10

Eyal Azulay


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>
like image 33
Ali80 Avatar answered Oct 21 '22 15:10

Ali80