Announcement Announcement Module
Collapse
No announcement yet.
the request was rejected because no multipart boundary was found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • the request was rejected because no multipart boundary was found

    Hi
    Im trying to do an uploader using jquery and spring mvc, but when I try my upload I get: Caused by: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

    My jquery code is:

    function upload() {
    var url = 'upload.htm';
    if (validarCamposLlenos()) {
    $.ajax({
    type: "POST",
    url: url,
    data: $('#miFile').attr('files'),
    cache: false,
    contentType: 'multipart/form-data',
    processData: false,
    beforeSend: function (x) {
    x.setRequestHeader('Content-Type', 'multipart/form-data');
    },
    success: function(data)
    {
    alert(data);
    },error: function(e)
    {
    alert('Error: ' + e);
    }
    });
    }
    }
    And in my controller Ive:

    @RequestMapping("/upload.htm")
    public String upload(
    @ModelAttribute(ConstantesAdminCertClient.ADMINCER TCLNT)
    final AdminCertClientBean bean,
    final BindingResult result,
    final ModelMap model,
    @RequestParam MultipartFile file,
    final HttpServletRequest request,
    final HttpServletResponse response) throws IOException{
    final String forward = ConstantesAdminCertClient.ADMINCERTJSP;
    try {
    logger.info("file: "
    + file.getOriginalFilename());
    } catch (Exception e) {
    logger.error(e);
    }
    model.addAttribute(ConstantesAdminCertClient.ADMIN CERTCLNT, bean);
    return forward;
    }
    If I try:

    $.ajax({
    type: "POST",
    url: url,
    data: $('#miFile').attr('files'),
    cache: false,
    contentType: false,
    processData: false,
    beforeSend: function (x) {
    x.setRequestHeader('Content-Type', 'multipart/form-data');
    },
    success: function(data)
    {
    alert(data);
    },error: function(e)
    {
    alert('Error: ' + e);
    }
    });
    }

    I get Failed to load resource: the server responded with a status of 400 (Bad Request) So its not being sent to the server.

    Does anyone knows, what wrong with my code?

    Thanks in advance.
Working...
X