Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting original file name of uploaded file grails

I am getting the uploaded file using request.getFile("file") where "file" is the name of file input element in my gsp file. I am able to parse this file fine but when I try to get the file's original name, I encounter the following error

No signature of method: org.springframework.web.multipart.commons.CommonsMultipartFile.getOriginalFileName() is applicable for argument types: () values: [] Possible solutions: getOriginalFilename()

This is my code:

def f = request.getFile("file")
def name = f.getOriginalFileName()

Why can't I call the getOriginalFileName() method on 'f', I thought request.getFile() returned a MultipartFile object

like image 572
Ameya Avatar asked Jul 24 '12 18:07

Ameya


2 Answers

The exception shows that it's a capitalization issue on method call f.getOriginalFileName() -> f.getOriginalFilename().

like image 103
schmolly159 Avatar answered Oct 30 '22 05:10

schmolly159


This is my code, which worked for me:

def uploadedFileName = request.getFile("file")    
def fileName = uploadedFileName.originalFilename
like image 40
Jayabalaji Somasundaram Avatar answered Oct 30 '22 05:10

Jayabalaji Somasundaram