Uploading Image to Directory using Servlet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NitinSawant
    Contributor
    • Oct 2007
    • 271

    Uploading Image to Directory using Servlet

    Hello Frendz,
    I'm trying to develop Servlet which simply uploads image to particular directory with unique name.

    i have wrote following form:
    which has two fields filename and the actual file.

    Code:
    <html>
    <head></head>
    <body>
    <form action="UploadImageServlet" method="POST">
    Select Photo: <input type="file" name="txtPhoto" size="20" /><br/>
    FileName: <input type="text" name="txtName" size="20" /><br/>
    <input type="Submit" value="Submit" />
    </form>
    </body>
    </html>
    I know the logic but don't know the code to upload selected image to particular directory..

    help needed.

    regards,
    Nitin Sawant
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    This has been done so many times before; does this help? All I did was google for file upload to servlet.

    kind regards,

    Jos

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      A more popular one is Apache's commons-fileupload API.
      Also reachable from Google.

      Comment

      • NitinSawant
        Contributor
        • Oct 2007
        • 271

        #4
        Apache's Commons API

        I've found links on net:-



        Comment

        • NitinSawant
          Contributor
          • Oct 2007
          • 271

          #5
          I also found sample code

          Comment

          Working...