FTP server Setup and upload and download learning

Source: Internet
Author: User
Tags ftp file ftp server path ftp site ftp upload file

The first steps to build the FTP service are as follows:

1. Start the FTP service on the Win7: Click OK here, you may have to wait a while, after the completion of the system will sometimes prompt to restart

2. Turn on the computer--"manage--" Here we can see the service that we just added (IIS)

3. Create an FTP site

4. Click Add FTP site, is to continue to add the necessary site information, here is: Site name and login FTP after the site specified directory (folder), click Next

5. The address of the site to write their own IP is good, port 21, is the default port of FTP, (port arbitrary, try not to use the port number has been occupied)

6., here to fill in the user, Basic is the user on this computer, anonymous is anonymous password as long as it is in accordance with e-mail format can be logged in for example: "[email protected]", Baidu said not to write empty can also, did not try, sometimes can it;

Access rights as the name implies, for users on the computer

Read and write do not say the click Finish, the successful establishment of an FTP site

7. After the establishment is like this, right click on the site you set up, start just fine. (This is the site I built earlier)

8. Users, users are using the system of the current Windows users can also create one of their own, in particular, the user-right button to select a new user, to fill in their own user name and password

10. Such an FTP site has been created, can be in the browser, or in the window to enter: Ftp://192.168.1.151:21 Enter to see their own designated space, if there is a user name password then enter the user password click OK, We can also set permissions on the FTP site and so on, such as: Click in to set the appropriate permissions

11. So the FTP site is completed, the first method may also want us to open the service often, but also note that we are currently using the port number has been occupied, if already occupied, it will need to modify the port number, Method may require us to re-establish an FTP site (small partners have any better suggestions can comment on the message), if it is their own computer, the service can be set to manual, if the company, then according to the corresponding needs to change.

The following is to introduce the second method, the second method is relatively simple, is to use already ready-made filezillaserver this software, the software is small and practical, a total of 2 m, on the Baidu search download and install Open is good basically all with the default settings is enough

12. Open after this interface, we use the local address, the port where the default 14147 is good, in fact, or 21, to modify the port, the first time you log in to FTP, after the colon after adding their own want to modify the port number is good,--> click to connect

13. Add login user in edit-->users, give user name, corresponding address, and corresponding permission

Add password

14. Click OK, such an FTP service is also set up, this can be more intuitive to look at the log, in addition, in the edit-->settings can also modify the settings of the log, OK this is the second method, the second method looks more simple, Above is the two methods of building FTP service on Win7, I novice small white, please advise!

Some people will say that I upload or download the file why less 1kb ah, or, I upload the file is damaged, cannot open, TXT can also open, but the other is not good to say, or upload pictures, the tail has a section of data loss, to tell the truth I also appeared this problem, The final discovery is the version of the jar package, FTP upload is to add the jar package Apache this jar package: Commons-net-3.3.jar, this jar package version is 3.3, transmission is not a problem, but if you use commons-net-3.0.jar,3.0 this version will have a feature bug, will cause a few According to the tail loss, its transmission is only an integer KB file, meaning that his transmission method is to take the whole KB, For example: 166.7KB, after the transmission will only have 166.0kb, the corresponding in 3.0.1 after the bug can be fixed, so in case you meet without urgency, as long as a newer version of the jar package is better, I test, very useful!

The above is transferred from: 73913586

There is a Linux environment to build the method, because do not have the conditions I did not kiss, but can refer to: https://www.cnblogs.com/xiaojiaocx/p/6410015.html

Related Learning links for FTP operations (settings for deletion, character encoding settings, workflow, etc.): 51150162

Here is the code of your own study:

 Public classFtpclienttest {/** * Create FTP Upload file method * @param URL host address * @param port host Port number * @param uname username * @param pword Password * @param pathname FTP server path to save files * @param filename File name * @param inputstream input stream * @return*/     Public StaticBoolean uploadfile (String URL,intport,string uname,string pword,string pathname,string filename, InputStream inputstream) {Boolean issuccess=false; FtpClient ftpclient=NewFtpClient ();//Create a FtpClient object

Character encoding for transmission (anti-garbled)
Ftpclient.setcontrolencoding ("UTF-8");

Timeout (prevent FTP zombie)
Ftpclient.setconnecttimeout (1000 * 60);
Ftpclient.setdatatimeout (1000 * 60);
Ftpclient.setdefaulttimeout (1000 * 60);

The size of the workflow
Ftpclient.setbuffersize (1024 * 4);

Primary passive mode (should be related to FTP server security settings)
Ftpclient.enterlocalpassivemode ();
Ftpclient.enterlocalactivemode ();


Try{ftpclient.connect (URL, port); //Create a connection by FtpClient object and URL and port numberFtpclient.login (uname, Pword);//to sign in intReply = Ftpclient.getreplycode ();//look at the return value is not 230, if yes, indicates a successful login//System.out.println ("What is the return value??") ----"+reply); /*if (! Ftpreply.isnegativepermanent (Reply)) {//satisfies this condition means the connection fails ftpclient.disconnect (); return issuccess; }*/Boolean C= Ftpclient.changeworkingdirectory (pathname);//set up your work space//System.out.println (c);Boolean b = ftpclient.storefile (filename, inputstream);//Uploading Files//System.out.println ("uploaded successfully???? ----"+b);Inputstream.close ();//close the input streamFtpclient.logout ();//Sign OutIssuccess =true; } Catch(SocketException e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } returnissuccess; } /** * Create FTP Download file method * @param URL FTP service address * @param username FTP user name * @param password FTP user password * @pa Ram filepath FTP Download filename * @param the relative path of the RemotePath FTP file * @param the port number of the Port FTP server * @param localpath the Save bit of the downloaded file Place * @return*/ Public Staticboolean downfile (String url,string username,string password,string filename,string RemotePath,intport,string LocalPath) {Boolean Success=false; FtpClient FTP=NewFtpClient ();//Create a FtpClient object Try{ftp.connect (URL, port); //Create a linkFtp.login (username, password);//log in to the FTP service intCode = Ftp.getreplycode ();//gets the returned reply value of 230 for successful connectionFtp.changeworkingdirectory (RemotePath);//Transfer to FTP server directoryftpfile[] files = ftp.listfiles ();//get all the filenames by Listfiles () for(Ftpfile file:files) {if(File.getname (). Equals (filename) {//find a matching file name to downloadFile LocalFile =NewFile (localpath+"/"+filename); OutputStream OS=NewFileOutputStream (LocalFile); Boolean b=ftp.retrievefile (filename, OS); System. out. println ("Did the download succeed??? ---"+b); Success=true; } } } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } returnsuccess; } Public Static voidmain (String [] args) {Try{FileInputStream fis=NewFileInputStream (NewFile ("D:/QCQ Company Profile/test.txt")); //Boolean flag = UploadFile ("192.168.2.90", +, "Qcq", "Qcq", "Test", "Test1", FIS); //Verifying the Upload file//System.out.println ("----------" +flag);Boolean b= Downfile ("192.168.2.90","Qcq","Qcq","test1","/test", +,"D:/QCQ Company Profile");//Verifying the download fileSystem. out. println ("----------"+b); } Catch(FileNotFoundException e) {//TODO auto-generated Catch blockE.printstacktrace (); } }}

FTP server Setup and upload and download learning

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.