我正在实现多个文件上传功能。
我的表格如下:
<form controller="upload" action="uploadfiles" method="post" enctype="multipart/form-data">
Upload Form: <br/>
<input type="file" name="srcFile" multiple/>
<input type="submit"/>
</form>
我正在尝试将控制器中的文件作为
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")
}
当我选择文件并点击提交时,我收到以下错误:
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
任何人都可以帮助我!
由于