views:

62

answers:

1

I've seen various Grails plugins which allow easier handling of file uploads, however these tend only to support a single file per form-submit.

I'd like a multi-attach form where as soon as you pick one file, an extra field and button is added using JS (various sites do it like this).

Do you know of any good plugins which provide elegant uploading of multiple files without excessive coding? A progress bar either per-file of for the whole process would also be very nice.

I don't know to what extent I can allow GORM to handle a java.io.File field (or in this case a Collection<File>).

+1  A: 

Try this tutorial - it uses a combination of jQuery and Flash: http://webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/

Though it's no Grails Plugin; but it doesn't matter as the plugin wouldn't do anything different (just adding some convenience tags and configs, probably).

Your second part of the question: How to save the files with your domain class. My advise: don't do that. If it's just a single thumbnail you want to store it would be fine. But as soon you have multiple/big files stored it just slows down your DB. Store binary data on the file system and reference their path+filename in the domain:

class UploadedFile {

  String name
  String pathToFile
  String fileType
}
david