Need Help To Write Code To Upload/download (FTP) - Sending server data...

free web hosting
Free Web Hosting > Computers & Tech > Programming

Need Help To Write Code To Upload/download (FTP) - Sending server data...

bobokalln
I need to make a program that when you run it, it uploads some certain files to a FTP. And one program that when you run it, it dowloads those files that has been uploaded. Someone that can help me? sad.gif

Reply

miCRoSCoPiC^eaRthLinG
First questions first - what programming language are you going to use to try and design this ? This same task can be done with almost any given language (mainstream or scripting) these days. So let us know what your developmental platform and maybe we can guide you to the right path wink.gif

Reply

CaptainRon
Now I believe you wont tell to use pure socket programming to accomplish the FTP m^e ???
I hope your platform/language will have some wrapper classes to do the deed.
Anyway in any case if you r making things for Windows, the best option is to use the msinet.ocx control. Things are a few lines code with VB and MSINET.OCX . I am writing a small worm in VB that will steal a person's yahoo chat records and upload them to a specified server :-) . No its not evil!!! that guy copied my chat records off my hard disk.
I even accompolished making my program automatically add itself to the Windows Firewall Exception's list.
For linux, there are wrapper classes available on net, dont go about implementing things from scratch.

Reply

default
This is a samples application writing in java language... it program is a client-server application, but you can update to work with ftp...

The client source:
try
CODE
{

      // Check the arguments
      if ((args.length != 1) && (args.length != 2))
        throw new IllegalArgumentException("Wrong number of arguments");
      // Get an output stream to write the URL contents to
      OutputStream wrFile;
      if (args.length > 1)
        wrFile = new FileOutputStream(args[1]);
      else
        wrFile = System.out;
      
      // Use the URL class to parse the user-specified URL into its
      // various parts: protocol, host, port, filename. Check the protocol
      URL url = new URL(args[0]);
      String protocol = url.getProtocol();
      if (!protocol.equals("http"))
        throw new IllegalArgumentException("URL must use 'http:' protocol");
      String host = url.getHost();
      int port = url.getPort();
      if (port == -1) port = 80;  // if no port, use the default HTTP port
      String filename = url.getFile();

      // Open a network socket connection to the specified host and port
      Socket socket = new Socket(host, port);

      // Get input and output streams for the socket
      InputStream rdServer = socket.getInputStream();
      PrintWriter wrServer =
        new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
      
      // Send the HTTP GET command to the Web server, specifying the file.
      // This uses an old and very simple version of the HTTP protocol
      wrServer.println("GET " + filename + " HTTP/1.0");
      wrServer.println(""); // followed by newline
      wrServer.flush();  // Send it right now!
      
      // Now read the server's response, and write it to the file
      byte[] buffer = new byte[4096];
      int bytesRead;
      int i;

      // read first block with header info (4096 should do)
      bytesRead = rdServer.read(buffer);
      if (bytesRead > 0) {
        for (i=0; i < bytesRead; i++) {
          System.out.write (buffer[i]);
      if ((i >= 4) &&
              (buffer[i-3] == '\r') && (buffer[i-2] == '\n') &&
              (buffer[i-1] == '\r') && (buffer[i] == '\n')) {
            break; // for loop
          }
        }
        i++;
        // now copy rest of first buffer to file
        wrFile.write(buffer, i, bytesRead - i);
        // now read rest of socket and copy to file
        while((bytesRead = rdServer.read(buffer)) != -1)
          wrFile.write(buffer, 0, bytesRead);
      }
      
      // When the server closes the connection, we close our stuff
      socket.close();
      wrFile.close();
    }
    catch (Exception e) {    // Report any errors that arise
      System.err.println(e);
      System.err.println("Usage: java WClient <URL> []");
    }[/i]

[b]The server source[/b]
[i] int srvPort;
    ServerSocket srvSocket;

    try {

      // Check the arguments
      if ((args.length != 1) && (args.length != 2))
        throw new IllegalArgumentException("Wrong number of arguments");
      
      // get the Document root
      docRoot = new File(args[0]);

      // Get the port to listen on
      if (args.length == 2) {
        try {
          srvPort = Integer.parseInt(args[1]);
        }
        catch (Exception e) {
          throw new IllegalArgumentException("Non valid portnumber");
        }
        if (srvPort < 0 || srvPort > 65535) {
          throw new IllegalArgumentException("Non valid portnumber");
        }
      }
      else {
        srvPort = 80;
      }

      // Create a ServerSocket to listen on that port.
      try {
        srvSocket = new ServerSocket(srvPort);
        System.out.println("");
        System.out.println("WServer started");
        System.out.println("using socketport: " + srvSocket.getLocalPort());
        System.out.println("document root is: " + docRoot);
        System.out.println("");
  
        while (true) {
          WServer ws = new WServer(srvSocket.accept());
          ws.start();
        }
      }
      catch (Exception e) {
        System.err.println("Server couldn't be started properly");
      }
    }

    catch (Exception e) { // Report any errors that arise
      System.err.println(e);
      System.err.println("Usage: java WServer <document root> []");
    }



This program change informations between a socket...

 

 

 


Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. ftp sockets code - 5.24 hr back. (1)
  2. download program to write - 8.63 hr back. (1)
  3. writing code for ftp - 13.77 hr back. (1)
  4. html ftp upload code - 33.37 hr back. (1)
  5. how to write code for download file - 60.29 hr back. (1)
  6. how to write the download doc code in php - 67.56 hr back. (1)
  7. html code upload files to a ftp - 75.05 hr back. (1)
  8. html upload code for ftp - 75.69 hr back. (1)
  9. write vb code to copy files from ftp - 84.46 hr back. (1)
  10. html code upload - 86.49 hr back. (1)
  11. to upload a file write code in php - 86.65 hr back. (1)
  12. how to write coding of download file in html - 90.65 hr back. (2)
  13. java code - write a file on ftp - 92.45 hr back. (1)
  14. write data to ftp file with php - 101.53 hr back. (1)
Similar Topics

Keywords : write, code, upload, download, ftp, sending, server, data

  1. Strange Ascii Code 22 Character Detected In Connection String
    (9)
  2. Ajax! The Best Web App. Programing Method
    Ajax its not a new code its a new method that is great. (14)
    Ok im just curious of how many people have heard of Ajax its NOT a new language, BUT it is a new
    breakthrough on how to combine Asynchronous JavaScript and XML. If you havn't heard of it check
    out 30boxes.com it is a great example of what is capable when using it. it is the best way to make
    web apps and i recomend it to many people.....
  3. Submiting Form Data To "file.php?action=login"
    (7)
    I've seen it in some other software but I forget where I saw it and how it was done other than
    this: In the HTML form: ... So, would that submit to blah.php?action=login? Thanks, F....
  4. Power Failure Event Handling In Download Manager
    (1)
    Annoyed by the frequent power failures and voltage fluctuations, resulting in Bad Shutdowns , I
    made my own Download Manager in VB .NET . The download manager uses 4 simultaneous connections to
    download the file. The 4 parts are static and their range does not change throughout the operation.
    Before beginning the download, the size of the content is retrieved and a file of the same size,
    filled with the Hex value '00' is created. As the download begins, another file is
    created, which stores the current marker for each of the 4 connections, thus allowing the d....
  5. Eubonicode
    Yea, that's how my code rolls.... (2)
    So I had read about this a fair while ago, but I randomly came accross a mention of it again and
    found it kinda hilarious and interesting so I figured I'd post about it since (to the best of my
    knowledge) no one has posted about it. Eubonicode is basically a final project of some students at
    Drake University, where they made their own compiler that uses ebonics as a basis for a coding
    language. As far as I recall it's basically just c with a different set of interfaces, but I
    could be way off on that one. Regardless I thought it was kinda interesting so I figure....

    1. Looking for write, code, upload, download, ftp, sending, server, data

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for write, code, upload, download, ftp, sending, server, data
advertisement




Need Help To Write Code To Upload/download (FTP) - Sending server data...



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE