Kurirux Kurirux - 1 year ago 142
Java Question

play framework file upload

I'm trying to add file uploading handling in play framework app to existing form with text field.
According to documentation, I need to use

method, however, it can not handle text input fields. Is it possible to use one controller for standart html form and file processing at the same time?

Answer Source

Yes, it is possible, just simply handle file and text input separately. For instance:

public Result myControllerMethod(){
  //handle input text here
  Form<MyModel> myForm = formFactory.form(MyModel.class);
  MyModel myModel = myForm.bindFromRequest().get();
  //handle file
  MultipartFormData<File> body = request().body().asMultipartFormData();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download