0

I am trying fileupload using ajax in a struts2 framework webapp. I am using the "fileupload" interceptor in the action mapping, i am getting the file content in the action, but not the uploaded fileName i.e.,

private File file; // + its setters & getters methods.
private String fileName; // + its setter & getters methods.

System.Out.println(file.getName()); //prints some .tmp file 

The fileName variable is null.

Do i have to specify any file Details while making an ajax call to get the FileName of the uploaded file ?

-- Thanks

Sangram Anand
  • 10,526
  • 23
  • 70
  • 103

2 Answers2

1

It should be like this

if the "name" attribute of the on your page is "xxx"

private File xxx;
private String xxxContentType;
private String xxxFileName;
Gopal
  • 1,292
  • 3
  • 19
  • 41
0

FileUpload Interceptor

You should provide setter method appropriately. Follow naming convention carefully. Refer above link

Struts2 FileUpload Example

MohanaRao SV
  • 1,117
  • 1
  • 8
  • 22