<input type="file"> reads only file name not full path

Posted by Deep on Stack Overflow See other posts from Stack Overflow or by Deep
Published on 2011-03-16T15:59:26Z Indexed on 2011/03/16 16:10 UTC
Read the original article Hit count: 166

Filed under:
|
|
|

I am using Glassfish Server.I have seen the apache file upload to solve it...but i want to implement it in glassfish server.

image.html

<form action="" method="post" enctype="multipart/form-data">
   Select a file:
        <input type="file" name="first" id="first"/>
         <br />
        <input type="button" name="button" value="upload" id="button" />
          <p id="test"></p>
      <img src='Unknown.png'  id="profile_img" height="200px" width="150px"/>
</form>

  test.js

$(document).ready(function() {
        var filepath= $("#first");
        $('#button').click(function() {
            $.ajax({
                    type:       "post",
                    url:        "imageservlet",
                    data:           "user="+filepath.val(),
                    success:    function(msg) {
                        $("#profile_img").attr('src',msg);
                        $("#test").html(msg)
                                  .fadeIn("fast");
                    }
            });
        });
});

     imageservlet.java

 String user=request.getParameter("user");
 out.print(user);

the output is file name not full path.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html