-
Jan 29th, 2013, 01:37 PM
#1
the request was rejected because no multipart boundary was found
Hi
I´m 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 I´ve:
@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 it´s not being sent to the server.
Does anyone knows, what wrong with my code?
Thanks in advance.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules