Pular para o conteúdo principal

Two plus ways to transfer files via FTP in Windows

Two plus ways to transfer files via FTP in Windows: "
While writing the Core FTP LE Product Spotlight blog post, I discovered a new way to transfer files using FTP. It led me to wonder how many other people were unaware of the two-plus ways to transfer files via FTP using only the tools provided in Windows.

I will briefly discuss each method using Windows 7 in the examples below. These instructions will also work in Windows Vista. Each method uses a different component of Windows to initiate the transfer:

  • Internet Explorer 8
  • Windows Explorer
  • DOS command line


Method One - Internet Explorer 8


Everyone who browses the Internet should be familiar with the addresses that are typed in the browser address bar to access a Web site, for example:

http://www.microsoft.com/

The address for FTP access is similar:

ftp://ftp.microsoft.com/

Type a public FTP site address like Microsoft’s (Figure A) in the address bar and press [Return] and you can find knowledge base articles, patches, updated drivers, utilities and documentation - though the information there is now dated. View the readme.txt files at the site for more information. If you successfully connect you should see the root directory. You can click on a directory to access sub-directories and files. Download a file by Right-clicking on the file and selecting Save Target As…

This blog post is also available in the PDF format in a TechRepublic Download.

Figure A


FTP from Internet Explorer 8

Note: Tools | Internet Options | Advanced tab | Enable FTP folder view (outside of Internet Explorer) and the Use Passive FTP (for firewall and DSL modem compatibility) options under Browsing should be checked by default. If not, enable these options.

Non-public sites require a user name and password (Figure B). This is convenient for listing the files on the remote FTP server, but if you are using IE 7 or IE 8 you will need to launch Windows Explorer to transfer files. (See Figures C, D, E and F)

Figure B



Non-public sites require a user name and password

Figure C



Select Page | Open FTP Site in Windows Explorer to open Windows Explorer. Alternatively, you can select View | Open FTP Site in Windows Explorer from the menu.

Figure D



Click Allow when the Internet Explorer Security window opens.

Figure E



Enter your user name and password and select Log On to connect using Windows Explorer.

Figure F



If you connect successfully you should be able to transfer files to and from the FTP server just as you would with any local drive.

Method Two - Windows Explorer


Method one is rather awkward. You can connect to the remote server directly in Windows Explorer (Figure G and H).

Figure G



Open Windows Explorer and type the FTP address in the address bar.

Figure H



Enter return after typing the address and you will be prompted for a user name and password.

But what if you routinely connect to a FTP server? You don’t want to have to type the FTP address each time you want to connect. There are three ways to create a shortcut or link for quick access. First, connect to the FTP server in Windows Explorer.

Option one - Create a desktop shortcut


There are two ways to create a desktop shortcut for a file or folder for quick access:

  • Select the remote file or folder and press and hold down the [Ctrl][Shift] keys. Drag and drop the file or folder to the desktop.
  • Right-click on the remote file or folder and hold down the right mouse button. Drag and drop the file or folder to the desktop. Select Create shortcuts here.

Option two - Create a link under Favorites


There are two ways to create a link to a folder for quick access:

  • Drag and drop a remote folder to Favorites in the navigation pane.
  • Right-click on the remote folder and then hold down the right mouse button. Drag and drop the folder to Favorites in the navigation pane. Select Create shortcuts here.

Option three - Create a link under Computer


The Add Network Location Wizard will create a link under Computer in the navigation pane. Right-click on Computer in the navigation pane then select Add a network location to open the Add Network Location Wizard. For a complete step by step guide, please visit the associated TechRepublic Photo Gallery.

FTP folders in Windows Explorer


A Microsoft spokesperson sent me the following information about the features and limitations of FTP folders in Windows Explorer:

“FTP Folders work natively in the Windows Explorer and allow users to:

  • Browse them, in a limited way (no metadata or thumbnails)
  • Copy, move and delete files and folders
  • Create new folders
  • Search/filter the current view
  • Add to favorite links
  • Open Files using the Common File Dialog

Unsupported behavior:

  • You cannot copy or move files between folders on the server, only to and from your PC
  • There are no thumbnails, metadata or previews
  • You can only save to FTP folders using the Common File Dialog if the application supports opening from a virtual namespace (which is rare)
  • You cannot see Unicode file names
  • There are no secondary streams”

Method Three - DOS command line


The ftp.exe executable is a Windows utility that can be started from a command prompt window command line. You can manually transfer files using the FTP utility but the power of this method is automation. It is a very convenient way to schedule and automate the regular transfer of files.

To view help for the FTP utility open a command prompt window and type ftp -? [Return] at the command line. To view the commands available in FTP type ftp [Return] to start the FTP utility then type ? [Return] at the FTP prompt. Type bye [Return] at the FTP prompt to exit the FTP utility.

You can create batch files and FTP scripts in order to automate the file transfer process. In the following examples, replace the italicized text with your unique host name, user name, password, local path and remote server directory.

Editor’s note: The following commands are examples. You will have to adjust drive letters and folders to match your system.

Transfer a single file


Type the following into Notepad and save as H:\TransferTest\transfer.bat:

ftp -v -n -s:H:\TransferTest\transfer.ftp

This is what the ftp command does:

  • ftp - Invoke FTP utility
  • -v - Suppress display of remote FTP server responses
  • -n - Suppress auto-login
  • -s: - Specifies the path including the name of the file containing FTP commands. Note: The path cannot contain spaces.

Type the following into Notepad and save as H:\TransferTest\transfer.ftp:

open example.yourhostingsite.com

user yourusername

password

cd /public_ftp/test

put “W:\pecos-softwareworks\shtml\changes_to_the_windows7_taskbar_you_should_know_about.shtml”

bye

This is what the FTP commands do:

  • open - Opens the remote FTP server
  • user - Log in using the user name
  • password - Log in using the user password
  • cd - Change to the specified remote directory where you want to upload the files, /public_ftp/test in this example
  • put - Upload the specified local file. The quotation marks are optional if there are no spaces in the path.
  • bye - Quit FTP session and exit FTP

Tip: FTP commands can be abbreviated to three characters so you may see scripts written with commands like binary abbreviated to bin.

Tip: Long path names can be time consuming to type and easy to mistype. You can simplify the process by using one of these methods:

  • Navigate to the file in Windows Explorer, Right-click on any part of the breadcrumb style address in the address bar and select Copy address as text. Paste the address into your FTP script file and add the file name.
  • The full path including the file name can be copied to the clipboard. Right-click on a file in Windows Explorer, select Properties and click the Security tab. Select and copy the full path next to Object name: and paste it into your FTP script file.

From a command prompt type H:\TransferTest\transfer.bat or open the batch file to run it. You may see a Windows Security Alert (Figure I and J):

Figure I



Select the Public networks option and click Allow access.

Figure J



The put command uploads one file from the client to the server. If the file already exists on the remote server it will be overwritten.

Use the get command to download one file from the server to the client.

Transferring multiple files


Type the following into Notepad and save as H:\TransferTest\multiple_transfer.bat:

cd /D W:\pecos-softwareworks\shtml

ftp -v -n -s:H:\TransferTest\multiple_transfer.ftp

Type the following into Notepad and save as H:\TransferTest\multiple_transfer.ftp:

open example.yourhostingsite.com

user yourusername

password

cd /public_ftp/test

prompt

mput “changes_to_the_windows7_taskbar_you_should_know_about.shtml” “a_case_of_maxtaken_identity.shtml”

lcd \Projects\PSWW\VIC\Package

binary

mput “vista_image_capture_1_1_2.zip” “vista_image_capture_1_2_0.zip”

bye

This is what the FTP commands do:

  • open - Opens the remote FTP server
  • user - Log in using the user name.
  • password - Log in using the user password
  • cd - Change to the specified remote directory where you want to upload the files, /public_ftp/test in this example
  • prompt - Disables interactive prompting when uploading multiple files using the mput command
  • mput - Upload the specified local ASCII files. The quotation marks are optional if there are no spaces in the path.
  • lcd - Change to the specified local directory containing the files that will be transferred, \Projects\PSWW\VIC\Package in this example
  • binary - Switch to the binary transfer mode
  • mput - Upload the specified local binary files. The quotation marks are optional if there are no spaces in the path.
  • bye - Quit FTP session and exit FTP

From a command prompt type H:\TransferTest\multiple_transfer.bat or open the batch file to run it. (Figure K)

Figure K



Multiple transfers

Note that I used the cd change drive and directory command in the batch file and the lcd change local directory FTP command in the FTP script to simplify the mput commands so that the relative path could be used instead of the full path.

Tip: Spaces can be problematic. Use underscore characters instead of spaces when possible.

The mput command uploads multiple files from the client to the server. If the files already exist on the remote server they will be overwritten.

Use the mget command to download multiple files from the server to the client.

There are other variations of this method including creating one batch file. I’ll leave it to you to explore them if you wish.

Transferring ASCII and Binary files


FTP handles transfers of ASCII (text) files differently from binary files. By default, the Windows FTP utility transfers files using the ASCII mode. The single file example above transfers one ASCII file. The multiple file example transfers both ASCII and binary files. To avoid possible data corruption, use the right transfer mode.

Security issues


There is one obvious security issue. If you have your user ID and password in an unencrypted text file it can be read by anyone with access to the computer so you will want to encrypt the FTP script file. Search for encrypt in Windows Help and click the Encrypt or decrypt a folder or file item or view these Microsoft Web pages for how to encrypt your data with Windows 2000, Windows Server 2003, Windows XP, Windows Vista or Windows 7. Wikipedia lists the Windows operating systems that support the Encrypting File System (EFS). You can also use a third party application like TrueCrypt.

Potential firewall issues


If you receive a 425 Unable to build data connection: Connection timed out error the problem is likely with your firewall. The FTP utility does not support the passive transfer mode and this can lead to firewall issues. I received this error using Comodo Firewall 4.0 and there are several workarounds that I can detail in the forum. If you are having this issue with your firewall you will need to configure the firewall to allow access for the FTP utility.

The final word


Before you go looking for a third party app take a closer look at the tools provided in Windows. One of the above methods may be the perfect solution for your FTP needs.

Susan Harkins makes a good point in Recommend clients using FTP switch to SSL or SSH that sensitive or confidential data should not be sent using the FTP protocol.

Additional resources


Microsoft Windows Command-Line FTP Command List - nsftools.com

Active FTP vs. Passive FTP, a Definitive Explanation - Slacksite.com

ASCII or Binary? Which Files Are Which - Webweaver

Stay on top of the latest XP tips and tricks with TechRepublic’s Windows XP newsletter, delivered every Thursday. Automatically sign up today!

Author’s Note


I would like to thank Microsoft for their help with this article.


"

Comentários

Postagens mais visitadas deste blog

Favigen, Favicon Generator

Favigen, Favicon Generator : " Favicons are small icons that help identify websites. They are used as a visual representation of a website both in the web browser and at many online services. The three most prominent locations of favicons are the browser’s address bar, the tabbar and the bookmarks folder. Many webmasters like to create custom favicons to add that custom identifier to their website. Favicons can be created in many image and icon editors, but also online. Favigen is a straightforward favicon generator that can turn an image into a favicon. All that it takes is to pick an image from the local hard drive first, select the dimensions of the favicon and click the submit button to make the service generate the favicon. Favigen supports several image formats, including jpg and png, and it does not seem to have size restrictions either. Available image dimensions range are 16×16, 32×32 and 64×64. The generated favicon is displayed directly on the page. A click on do...

A simple rsync script to back up your home directory

A simple rsync script to back up your home directory : " Backing up important data is obviously something we should all do. Unfortunately, it is not always easy to make it happen. We get lazy; we do not have the additional hardware for a backup server; it takes a long time and a lot of CDs to back up to optical media; we do not trust online backup services; backup schemes are difficult to set up and use — any of dozens of reasons can stand in our way. Still, we know we should be backing up our important data. Modern open source Unix-like operating systems offer a plethora of options for incredibly simple, effective backup schemes, however. If the problem is figuring out how to set one up, a simple rsync solution may be exactly what you need. The rsync utility is used to synchronize files between two systems. It does so by way of incremental copies, only copying from the source to the destination what has not already been copied there, saving time, network bandwidth, and syst...

Google Wave now open to the public: faster, Robots and Gadgets aplenty!

Google Wave now open to the public: faster, Robots and Gadgets aplenty! : " Filed under: Internet , Google If you somehow missed it, Google Wave is now a bonafide Labs project: rather than being an invite-only alpha, it's now a public beta test! If you don't already have an account, just head on over to Wave and use your regular Google login details. If you've not seen any of the Google Wave introductory videos , you should check them out -- they explain the whole thing a lot more succinctly than I ever could. Wave has also been enabled for Google Apps domains -- businesses could convert their internal communication to Waves today! Leading up to this public release there have a lot of changes. It's by no means finished, but Google Wave is now a lot faster . It's also more intuitive -- more useful -- and given the large number of Robots and Gadgets now reaching prime-time readiness, it feels like the mass adoption of Wave is imminent. Also, if you're an ol...