I have an HTML form with a text input named “name”, file upload input named “myFile” (shows Browse button), and a submit button (named “Upload”).
I accidentally pressed enter before I choose a file, and a file with 0 length was uploaded to the servlet. How to make sure the browser doesn’t post if the file is not selected, or the file name is empty… Thanks!
David, your comment is correct. The answer is to use javascript to check whether the text input is filled with info if manual input is required. I also could use the javascript to put the file name without the path to fill in the form automatically.