How do you get the filename from the XPages FileUpload Control

允我心安 提交于 2019-12-06 14:57:01

Actually you can get the file and fully manipulate it, read it, do whatever you want with it, its stored in the xsp folder on the server, to which you have read/write access... here is a code snippet that interacts with the file, I usually call from 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();
}
Toby Samples

It sounds like you are referring to needing to get the data via CSJS, which you can do with the following code:

var filename = dojo.byId('#{id:fileUpload1}').value.split('\\').pop();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!