开发者

How do you choose the filename of an uploaded file in ICEfaces?

How do you choose the filename of an uploaded file in ICEfaces with an ice:inputFile? The reason I want to do this is s开发者_如何学JAVAo that the user can upload multiple files with the same name, without them being overwritten by the server or causing an error.

I've tried setting the tag's submitOnUpload attribute to "preAndPostUpload" and making an uploadActionListener for that tag that changes the filename of the InputFile's FileInfo to a random string. If it tries to change the filename pre-upload, it gets ignored and the file is uploaded with the user-provided filename. If it tries to change the filename post-upload, I get a unhelpful NullPointerException. How do I choose the name the file is saved by?

JSF 1.2, IceFaces 1.8.2


Oh, I got it. Instead of calling FileInfo.setFileName, you want to call FileInfo.getFile().renameto().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜