Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I recently did this using Dojo Iframes. Here's the code for that (need to call it from action="return submitForm();" from the form tag):</p> <pre><code>submitForm = function() { dojo.io.iframe.send({ url : "/uploadForm", form : "html_form_id", method : "POST", handleAs : 'text', load : function(response, ioArgs) { //handle your response here... return response; }, error : function(response, ioArgs) { if (ioArgs.xhr.status != 0) { try { //handle error here } catch (e5) { } } return response; } }); return false; } </code></pre> <p>On the server side, in your Spring Controller, you would handle this as:</p> <pre><code> @RequestMapping(method = RequestMethod.POST, value = "/uploadForm") public ModelAndView onSubmit( @RequestParam("file") MultipartFile multipartFile, final HttpServletResponse response) throws Exception { String fileName=""; if(multipartFile!=null) { fileName = multipartFile.getOriginalFilename(); } //file inputstream can be accessed as multipartFile.getInputStream() String resultCode = "0"; final String responseHTML = "&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;textarea&gt;" + resultCode + "&lt;/textarea&gt;&lt;/body&gt;&lt;/html&gt;"; response.setContentType("text/html"); final OutputStream responseStream = response.getOutputStream(); responseStream.write(responseHTML.getBytes()); responseStream.write("\r\n".getBytes()); responseStream.close(); } </code></pre> <p>You'll need to name your file type input parameter as "file" (as the handling functions says @RequestParam("file"))</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload