How To Use FTP Through the Command Line


It is possible to upload files to your web server using the Windows command line. The command line has an inbuilt tool that will allow you to connect to your web server using FTP. However, I would recommend you not to use this as it is a bit difficult and you have to enter commands through the keyboards. There are many free FTP clients available on the Internet which will make it easier to work.

As you may be aware, FTP stands for File Transfer Protocol and is a way by means of which one can transfer files from one computer to another. FTP is the standard protocol that most web designers use to transfer files to their web servers from their computers. In fact, many tools like Dreamweaver, GoLive, etc come with an FTP client installed so that the user can upload files easily.

Here is how you proceed to use FTP through the command line. Note that the commands are NOT case sensitive and so you can type either in upper case or lower case letters.

Step 1: Open the command line

You can do this by going to Start>Run and then typing “CMD” and pressing Enter. Navigate to the correct folder which contains the files that you want to upload. For example if your files are on the D: , enter d: in the command prompt and it will switch to D:. I am using C: Drive.

Step 2: Connect to your server using FTP

Type “FTP” followed by your FTP address. This is shown below:

ftp command line login

In my case ftp.pcsplace.com is my FTP address. It will be like ftp.yourdomainname.com in your case.

Then enter your username and password. If it looks like the image shown below, it means you have successfully connected to your web server.

 ftp command line password

You might have observed that when you type your password, you won’t see anything on the screen, no dots or asterisk marks. This is to ensure the safety of your password.

Step 3: Uploading your files

In order to upload your files, first you will have to navigate to the correct directory. Usually, the root of your domain will be either “public_html” or “www”. However, in my case it is “/” i.e., Root directory. You can see the directories that are present on your web server by using the “DIR” command. Just enter “DIR” and you will see all the directories that are present.

To change to the directory the command is cd (i.e. change directory). Type cd followed by the name of the folder you want to change to.

Ex: cd uploads

You can check the current directory by typing PWD. Now let us upload a file. In my case, I will uploading a file called prasanthchandra.jpg. It is an image file. To do that we have to use the PUT command. Here is how that is done.

 ftp command line upload file

To upload a file, just type “put” followed by the name of your file and it will get uploaded. It will also provide you with statistics about the file like its size, how long it took to upload and your network speed.

Step 4: Verifying the Uploaded files

You should always verify that the files have been uploaded correctly. You can do this by pointing your browser to yourdomainname.com/nameoftheuploadedfile. If something goes wrong, you will have to upload the file again.

Step 5: Closing the FTP connection

You can close the FTP connection by typing “bye” at the FTP prompt.

ftp command line bye logout

If you wait for sometime, you will automatically get disconnected. This is for security reasons. You can use the command line feature if you don’t have any ftp client or if you are comfortable with command line. Leave your queries as comments..

Filed under: How To's
Tags: , , , , , ,
January 29, 2009 by: Prasanth Chandra

Comments

Leave a Reply