0

I am implementing multiple files upload functionality.

I have a form as follows:

<form controller="upload" action="uploadfiles" method="post" enctype="multipart/form-data">
            Upload Form: <br/>
            <input type="file" name="srcFile" multiple/>
            <input type="submit"/>
        </form>

I am trying to get the file in the controller as

def uploadfiles = {
        println "${request.getClass()}"
        def filename = request.getFile("srcFile")    

        if(!filename.empty){
            println "Class: ${filename.class}"
            println "Name: ${filename.name}"
            println "OriginalFileName: ${filename.originalFilename}"
            println "Size: ${filename.size}"
            println "ContentType: ${filename.contentType}"
        }
        filename.transferTo(new File('/home/vamshins/Documents/uploadpath/my.txt'))

        println "Transferred"

        redirect(action:"upload")
    }

when I selected the file and clicked on submit, I am getting the following error:

URI
/FindMissingIsirs/upload/uploadfiles
Class
java.lang.NullPointerException
Message
Cannot get property 'empty' on null object    URI
/FindMissingIsirs/upload/uploadfiles
Class
java.lang.NullPointerException
Message
Cannot get property 'empty' on null object

Can anyone please help me!

Thanks

emmanuel
  • 9,607
  • 10
  • 25
  • 38
  • `log.info params` and show us what gets submitted? – dsharew Feb 26 '15 at 07:24
  • 2015-03-06 09:47:40,391 [Thread-12] ERROR StackTrace - Full Stack Trace: java.lang.NullPointerException: Cannot get property 'cacheOperationSource' on null object at CacheGrailsPlugin$_closure4.doCall(CacheGrailsPlugin.groovy:184) – user2516554 Mar 06 '15 at 16:50
  • Did you get this from `log.info params`? – dsharew Mar 06 '15 at 16:52

0 Answers0