Results 1 to 2 of 2

Thread: Multiple file upload

  1. #1
    Join Date
    Apr 2011
    Location
    India
    Posts
    17

    Exclamation Multiple file upload

    I'm using spring roo 1.2 release.
    I want to do multiple file upload, by refering "roodocman project" i'm able to upload single file but not suceed in multiple file upload from same form

    for single file upload i've done following changes in server side:


    @RequestMapping("/employees")
    @Controller
    @RooWebScaffold(path = "employees", formBackingObject = Employee.class, update=false)
    public class EmployeeController {
    private static final Log log = LogFactory.getLog(EmployeeController.class);

    @InitBinder
    protected void initBinder(HttpServletRequest request,
    ServletRequestDataBinder binder)
    throws ServletException {
    // Convert multipart object to byte[]
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    }
    @RequestMapping(value="saveemp", method = RequestMethod.POST)
    public String createemp(@Valid Employee employee, BindingResult result, Model model, @RequestParam("photo") MultipartFile photo, HttpServletRequest request) {

    employee.setFilename(photo.getOriginalFilename());


    if (result.hasErrors()) {
    model.addAttribute("employee", employee);
    return "employees/create";
    }
    employee.persist();

    return "redirect:/employees?page=1&size=10"+encodeUrlPathSegment(emp loyee.getId().toString(), request);
    }




    Now what i should do so i can upload many file same time.

  2. #2
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    That was a useful quest indeed.
    One way to attack this kind of situation is to acknowledge we're using Spring MVC 3 and use a search engine to find what we need.
    I found spring 3 upload many files at stackoverflow in very little time. You'll have to translate the jsp to a jspx.

    Your question allowed me to share this finding here. I will try this solution myself in a current project, so thanks for asking! Let us know how it worked for you.
    Last edited by MiB; Feb 8th, 2012 at 07:13 PM.

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
  •