Download files to your web host directly

What do you do when you need to install any big sized scripts to your server?

Do you download the script files to your computer then upload it to your web host from your computer and install the script?

If you are doing this you are wasting your time.

You can simply use some methods to download files directly to your webhost or server.

So here are two ways for you to download files to your server directly.

You can use the first one if you have SSH enabled in your server and you want to download files from a internet website. You can use the second one if you don’t have SSH enabled in your server and you want to download file from a FTP server to your webhost.

1> Use SSH.

Using SSH to download files to your webhost from other websites is really simple.

First of all you should make sure that SSH is enabled in your webhost, SSH is enabled by default in most cases if you have a Private server or a VPS if you are on a shared hosting there is very little chance that you have SSH enabled. If SSH is enabled in your server the second step is to identify the location of file you want to download.

So now the third step is to download or use a SSH client software like “putty” (you can search in Google for that if you don’t know what is it) , login to your SSH server using SSH client software and navigate to the directory or location where you want to download the file.

Now after you are in the directory type the following codes in the SSH client software:

wget http://locationoffiletobedopwnloaded

2> Use PHP

If you want to moves files from a FTP server to your webhost then you can use this option.

So first of all identify the location of file in the remote FTP server that you want to download and the location where you want to save the file in your webhost.

Now copy following code and save it in a PHP file and upload to your server.

And run the PHP file. Or open the file location from your browser like if you have saved the code in “abc.PHP” file and uploaded to home folder of your site then open http://yoursite/abc.php

But open this page only once otherwise you will waste your server bandwidth.

Code:

<?php

$local_file = ‘location in your wbhost where you want to save the file. Eg: home/dir/name.zip‘;

$server_file = ‘location of file you want to download in remote FTP server. Eg: www/dir/name1.zip‘;

$ftp_user_name= ‘ftp username is FTP server

$ftp_user_pass= ‘ftp password in FTP server

$conn_id = ftp_connect($ftp_server);

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {

echo “Successfully written to $local_file\n”;

} else {

echo “There was a problem\n”;

}

ftp_close($conn_id);

?>



Popular Searches:



 

About the author

More posts by admin | Visit the site of admin