struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Givler, Eric" <>
Subject RE: get file path from FormFile
Date Wed, 17 Dec 2008 15:34:11 GMT
Would there be an issue with modifying the controller settings and setting the memFileSize
artifically low so the file is always written to disk, then gaining access to the filename
via reflection?

// create in package org.apache.struts.upload
public static String getFilePath( FormFile file ) {
   String path = null;
   Class formClass=CommonsMultipartRequestHandler.CommonsFormFile.class;
   Field fileItemField = formClass.getDeclaredField("fileItem");
   Object o = fileItemField.get( file );
   if ( o instanceof DefaultFileItem ) {
      DefaultFileItem df = (DefaultFileItem) o;
      File osFile = df.getStoreLocation();
      path = osFile.getPath();
   return path;

-----Original Message-----
From: elyes sallem []
Sent: Tuesday, December 16, 2008 6:24 AM
To: Struts Users Mailing List
Subject: get file path from FormFile

after publishing this question, i conclude that it is not possible de get back the absolute
path from FormFile but the problem is that i import a jar file, in which i call a method that
accept only path of file so what do you propose, i get the inputstream , then i create temporarly
a file and i delete it at the end or you have an other ideai?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message