Johnson nickel wrote:
Hi everyone,
I am using Struts 2 and using <s:file> tag to upload a file.
But I get that file as a 'File' object in my action class and using
getFileName() on that File object returns me some arbitrary value (something
like upload__5b41f107_1127b4befe0__8000_00000000.tmp). I want to
retrieve things like Filedata to store the binary datas in my databases.
which was possible in
struts 1.1 using methods like on getFiledata() using byte [] array FormFile
Object.
How do I accomplish the same in Struts 2 ?
Regards,
John
Hi John,
If the file property in your action is called "anUploadFile", then also
add the following properties to your action:
String anUploadFileContentType
String anUploadFileFileName
If you require any other kinds of filedata (eg. size) you'll have to
obtain it from the File object.
ie.
void setAnUploadFile(File file);
void setAnUploadFileFileName(String name)
void setAnUploadFileContentType(String contentType)
For more information, see the FileUploadInterceptor:
http://struts.apache.org/2.0.11/docs/file-upload-interceptor.html
regards,
Jeromy Evans
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]