CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    How to get the file content in the server, posted using <input type=file>


    Hi folks,

    i have one form that will send the client file to the server. The html code for this is

    &lt;form action="httt://servlet:8080/servlet/upload" Method= POST enctype="multipart/form-data"&gt;
    &lt;input type=file name=file_name&gt;
    &lt;input type=submit&gt;
    &lt;/form&gt;

    I dont know how to get the file content in the server server side using servlets.

    Do please let me know. My id is [email protected]


    Thanks in advance

    wilson.


  2. #2
    Join Date
    Jun 1999
    Location
    Atlanta, GA
    Posts
    57

    Re: How to get the file content in the server, posted using <input type=file>

    See this code..
    Posted some time back by Leon

    //(the class base64 encodes the attachment, there is just attachment without any message body)

    out.println("DATA");
    out.flush();

    line = in.readLine(); //354 ...
    if(!line.startsWith("354"))
    {
    System.out.println("ERROR: DATA");
    return;
    }

    //message:
    out.println("From: " + fromName + " &lt;" + from + "&gt;");
    out.println("Reply-To: " + from);
    out.println("X-Mailer: Java SMTP v1.0");
    out.println("MIME-Version: 1.0");
    out.println("To: " + to);
    out.println("Subject: " + subject);
    out.println("Content-Type: multipart/mixed; boundary="+(char)34+"=============0123456789=="+(char)34);
    out.println("");
    out.println("This is a multi-part message in MIME format.");
    out.println("");
    out.println("--=============0123456789==");


    out.println("Content-Type: application/octet-stream; name="+(char)34+filename+(char)34);
    out.println("Content-Transfer-Encoding: base64");
    out.println("Content-Disposition: attachment; filename="+(char)34+filename+(char)34);
    out.println("");

    base64 mm=new base64(attachment,attlen,out);

    out.println("--=============0123456789==--");

    out.println(".");
    out.flush();





    Hope this gives you some clues...

    Meher

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured