Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Having problem with <input type="file"..

    Hello,

    I have the following form element in my jsp page:

    <form method="post" enctype="multipart/form-data" action="<%=someUrl%>">
    <input type="file" name="userfile">

    which allows a user to select a filename by clicking on the browse button.

    In my servlet, I am trying to get the name of the file selected by the user as follows:

    String sFileName = request.getParameter("userfile");

    When I print out sFileName, it prints null. Does anyone have any idea or suggestion how to get this user entered filename in the servlet?

    Thanks a lot!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    When form encoding is "multipart/form-data" which is required for upload forms, you will not be able to retrieve form data normally (using request.getParameter)

    Have you heard of JspSmartUpload component?


  •  

    Posting Permissions

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