javascript - How to upload a file in just one click -


i have html page, gives option upload file server, there servlet action class @ server side & handles request , write file. here how works

  1. click browse file , select file
  2. click submit button.

but want upload in 1 click on button, please take of code , suggest how using javascript/jquery fn.

<html> <head>     <script type = "text/javascript">       function test() {          var uploadfile = document.getelementbyid("upload_id");         uploadfile.click();  // here can browse file without clicking on file brows button } </script>  </head> <body>    <input type="button" id="just_one_click" value ="click me" onclick="test();" />   <form action="upload.do" method="post" enctype="multipart/form-data">     <input type="file" id="upload_id" name = "fileupload" />    <input type = "submit" value="upload" />   </form>  </body> </html>  

you can assign id (let's 'myform') form , use document.getelementbyid('myform').submit(); instead of uploadfile.click();.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -