Change the upload directory path for an ice:inputF

2019-08-16 13:12发布

I've noticed that the ice:inputFile component will only upload files to the directory $TOMCAT_HOME/webapps/MyAppName/upload/. I want this directory to be dependent on the user initials for the current user (i.e. user with initials abc wants to upload a file, the file goes to $TOMCAT_HOME/webapps/MyAppName/upload/abc/). How can I dynamically set this attribute?

2条回答
不美不萌又怎样
2楼-- · 2019-08-16 13:49

Need to set the property uploadDirectory on the component, as such:

<ice:inputFile file="#{Bean.file}" uploadDirectory="./upload/#{Bean.userInitials}/"/>

This property is (currently) not mentioned in the JavaDoc for this component on the ICEFaces site.

查看更多
虎瘦雄心在
3楼-- · 2019-08-16 13:52

As indicated in the reference guide http://www.icefaces.org/docs/v1_8_2/htmlguide/devguide/references5.html

web.xml file:

To specify the directory location where uploaded files are stored, the following parameter is used:

<param-name>com.icesoft.faces.uploadDirectory</param-name>

<param-value>youruploaddirectory</param-value>

This parameter works in conjunction with the ice:inputFile component attribute "uniqueFolder" with four possible combinations as illustrated below:

                           **com.icesoft.faces.uploadDirectory**

                                   Set                                 Not Set

  **uniqueFolder**

   True           /app-context/uploadDirectory/sessionid/     /app-context/sessionid/

   False          /app-context/uploadDirectory/           /app-context/         

Note: The default upload directory specified via the configuration parameters above can be overridden on a per-instance basis via the uploadDirectory and uploadDirectoryAbsolute attributes on the ice:inputFile component.

Hope this helps!

查看更多
登录 后发表回答