Dav*_*edy 1 xpages xpages-ssjs
在XPages中,在文件上传控件中,用户选择文件后但在保存之前如何获取文件名?我对路径不感兴趣,因为我认为由于安全问题而无法通信,但我想尽可能获得文件名和扩展名.
谢谢!
实际上你可以获取文件并完全操作它,读取它,用它做你想做的任何事情,它存储在服务器上的xsp文件夹中,你有读/写访问权限......这里是一个与之交互的代码片段该文件,我通常从beforeRenderResponse调用...
var fileData:com.ibm.xsp.http.UploadedFile = facesContext.getExternalContext().getRequest().getParameterMap().get(getClientId('<INSERT ID OF UPLOAD CONTROL HERE (ie. fileUpload1)>'));
if (fileData != null) {
var tempFile:java.io.File = fileData.getServerFile();
// Get the path
var filePath:String = tempFile.getParentFile().getAbsolutePath();
// Get file Name
var fileName:String = tempFile.getParentFile().getName();
// Get the Name of the file as it appeared on the client machine - the name on the server will NOT be the same
var clientFileName:String = fileData.getClientFileName();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3191 次 |
| 最近记录: |