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
- click browse file , select file
- 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
Post a Comment