java - Get Full Path for uploaded Image -


i trying full path of uploaded image access in servlet , store in mysql database, have tried several methods everytime null value, need examples. thanks

here doing

       ----- in jsp ----- <div class="fileupload fileupload-new" data-provides="fileupload">     <div class="fileupload-preview thumbnail" style="width: 50px; height: 20px;"></div>     <div>         <span class="btn btn-file"><span class="fileupload-new">select image</span>         <span class="fileupload-exists">change</span><span></span><input id="myfile" onchange="showfilename()" runat="server" type="file" /></span>     </div> </div>  <script type="text/javascript">     function showfilename() {         var fil = document.getelementbyid("myfile");         var file = fil.value;         fil.setattribute("name", file)      } </script>      ------ in servlet ------- protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {      string image = request.getparameter("file");      system.out.println(image);      productdao pd = new productdao();      pd.insertproduct(image);      doget(request, response); }   ----- in dao -----  public void insertproduct(string d)  {      string sql = "insert product (images) values (?)";      try {          preparedstatement statement = thecon.preparestatement(sql);         file file = new file(d);          fileinputstream inputstream = new fileinputstream(file);          statement.setbinarystream(1, inputstream, (int) file.length());          int row = statement.executeupdate();          thecon.commit();      }     catch (sqlexception ex) {         ex.printstacktrace();     } catch (ioexception ex) {         ex.printstacktrace();     }         {         try {             thecon.close();         } catch (sqlexception e) {             // todo auto-generated catch block             e.printstacktrace();         }  } 


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -