FTP Upload file description

Source: Internet
Author: User
Tags ftp connection ftp site ftp upload file file transfer protocol ftp protocol ftp transfer

FTP Upload file description

1, install the IIS service in the operating system. The installation steps are as follows:

(1) Install the IIS server in the Windows system and put the installation CD in the CD drive. Open the control surface--"Select Add program as shown below:

(2), click "Add/Remove Windows Components", select the application, and select the item, then click "Details".


(3), click "Details", select "Internet (Information Services IIS)", and select this, click "Detailed information".


(4), click "Detailed Information" to select "File Transfer Protocol (FTP) protocol", click "OK".

2, configure the FTP protocol

(1), in "Computer Management" to find the FTP protocol service.

(2), select the FTP site, the right button "new", select "FTP site."

(3), according to the system prompts step-by-step implementation

Point "Next"

Enter "description" and click "Next"

Select the IP address used by the FTP site, ftp default port 21, click Next

Select "Do not isolate user", click "Next No"

Description: 1>: Do not isolate users when users connect to this type of FTP site, they will be directly directed to the same file, which is directed to the entire FTP site's home directory

2>: Isolate users you must create a dedicated subfolder for each user under the home directory of the FTP site, and the subfolder name must be the same as the user's login account, which is the user's home directory. When a user logs on to this FTP site, it is automatically directed to the user's home directory and does not have permission to switch to another user's home directory.

3>: Isolated user users with Active Directory must use domain user accounts to connect to this type of FTP site, and you must specify their dedicated home directory within the user account of Active Directory, which can be located in an FTP site. You can also be located on a different computer on the network. When a user logs on to this FTP site, it is automatically directed to the user's home directory and does not have permission to switch to another user's home directory.

Input file upload path, click "Next"

Select Read, write permission, and click Next

Click "Finish"


3, configure the program init.properties files.

SERVERIP=192.168.1.123//Configure server address

PORT=21//Configure FTP port

Username=administrator//Login Server user name

PASSWORD=123//Login Server password

serverpath=g:/test///File upload address

Uploadfile=d:/test/test.txt//Read the original file path

4, ftpclient upload file need jar package

Commons-net-1.4.1.jar

Jakarta-oro.jar

5, FtpClient part of the API introduction:

S un.net.ftp.FtpClient., this class library mainly provides classes for establishing an FTP connection. Using these classes, programmers can log on remotely to an FTP server, enumerate directories on the server, set up transport protocols, and transfer files. The FtpClient class covers almost all FTP functionality, and ftpclient instance variables hold various information about establishing a "broker." These instance variables are given below:

public static Boolean Useftpproxy

This variable is used to indicate whether an agent was used during FTP transfer, so it is actually a tag, which, if true, indicates the use of a proxy host.

public static String Ftpproxyhost

This variable is valid only if the variable useftpproxy is true, and is used to save the proxy host name.

public static int Ftpproxyport

This variable is valid only if the variable useftpproxy is true, and is used to save the port address of the proxy host.

FtpClient has three different types of constructors, as follows:

1. Public ftpclient (String hostname,int Port)

This constructor uses the given host name and port number to establish an FTP connection.

2. Public ftpclient (String hostname)

This constructor creates an FTP connection with the given host name, using the default port number.

3, FtpClient ()

This constructor creates a FtpClient class, but does not establish an FTP connection. At this point, the FTP connection can be established using the OpenServer method.

Once the class ftpclient is established, you can use this class method to open the connection to the FTP server. Class FtpClient provides the following two methods that you can use to open a connection to an FTP server.

public void OpenServer (String hostname)

This method is used to establish a connection to the FTP server on the specified host, using the default port number.

public void OpenServer (String host,int Port)

This method is used to establish a connection to the FTP server on the specified host, specified port.

After you open the connection, the next step is to register to the FTP server. The following methods need to be used.

public void Login (String username,string password)

This method logs on to the FTP server using parameter username and password. Users who have used Intemet should know that the anonymous FTP server's login username is anonymous and the password is generally in its own e-mail address.

The following are some of the control commands provided by the FtpClient class.

public void CD (String remotedirectory): This command switches the directory on the remote system to the directory specified by the parameter remotedirectory.

public void Cdup (): This command is used to switch directories on the remote system to the previous directory.

Public String pwd (): This command displays the status of the directory on the remote system.

public void Binary (): This command sets the transport format to binary format.

public void ASCII (): This command sets the transport protocol to an ASCII format.

public void rename (String string,string string1): This command renames a directory or file on a remote system.

In addition to the above methods, class FtpClient also provides several methods that can be used to pass and retrieve catalog listings and files. These methods return input and output streams that are available for reading or writing. Here are some of the main methods.

Public Telnetinputstream list ()

Returns the input stream corresponding to the current directory on the remote machine.

Public Telnetinputstream get (String filename)

Gets the file filename on the remote machine, using Telnetinputstream to transfer the file to the local.

Public Telnetoutputstream put (String filename)

Opens an output stream by writing to transmit file filename to a remote computer through this output stream

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.