Results 1 to 2 of 2
  1. #1
    dman is offline Member
    Join Date
    Aug 2009
    Posts
    5
    Rep Power
    0

    Default Automatically upload file to FTP server

    Hi everyone, :confused:
    i'm making an investigation about uploading files to FTP server, i googled about it and found the next sample code:

    Java Code:
    import org.apache.commons.net.ftp.FTPClient;
    import java.io.FileInputStream;
    import java.io.IOException;
    
    public class FileUploadDemo {
        public static void main(String[] args) {
            FTPClient client = new FTPClient();
            FileInputStream fis = null;
    
            try {
                client.connect("ftp.domain.com");
                client.login("admin", "secret");
    
                //
                // Create an InputStream of the file to be uploaded
                //
                String filename = "Touch.dat";
                fis = new FileInputStream(filename);
    
                //
                // Store file to server
                //
                client.storeFile(filename, fis);
                client.logout();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
                    }
                    client.disconnect();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    My question is: how can i automatically upload every file in certain directory, such as C:\upload. Everytime that i put a new file in that directory it should be uploaded.

    Thanks for your help! :D

  2. #2
    nap_patague is offline Member
    Join Date
    Mar 2011
    Location
    Bulacan, Philippines
    Posts
    23
    Rep Power
    0

    Default

    put it in a thread and check whether the new file is added to the directory
    Keep Moving Forward

Similar Threads

  1. Upload/download a file to/from server
    By karq in forum Networking
    Replies: 16
    Last Post: 08-24-2010, 09:43 AM
  2. Upload war file on server
    By sandeeprao.techno in forum Advanced Java
    Replies: 2
    Last Post: 12-16-2009, 10:55 AM
  3. :large file upload to server(chunk upload)
    By tommy_725 in forum Networking
    Replies: 0
    Last Post: 10-16-2009, 12:21 AM
  4. UPload a file to server?
    By makpandian in forum JavaServer Pages (JSP) and JSTL
    Replies: 10
    Last Post: 07-21-2009, 01:35 PM
  5. Automatically File Upload to server ...Help Needed
    By 82rathi.angara in forum New To Java
    Replies: 6
    Last Post: 08-05-2008, 07:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •