I am trying to store client logo into "src/main/webapp/clientImage/clientcode"
clientcode directory will be created based on different-2 client.
For Example if client Code is TEST then the complete path will be like "src/main/webapp/clientImage/TEST" and when we upload client image then client logo will come under "TEST" directory .
So after uploading client logo ( suppose image name is "test.jpeg" ,then complete directory will be "src/main/webapp/clientImage/TEST/test.jpeg".
The Code to upload client logo is::
`public boolean upload(UploadedFile uploadFile) {
String LOGO_PATH= "/clientImage/";
String fileName = uploadFile.getFileName();
String realPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath(LOGO_PATH + selectedClient.getClientCode());
File f = new File(realPath);
if (!f.exists()) {
f.mkdirs();
logger.debug("Directory created : {}", f.getName());
}
try {
new UserUtils().copyFile(fileName, uploadFile.getInputstream(), realPath);
selectedClient.setLogo(fileName);
saveClient();
FacesMessage msg = new FacesMessage("Success! ", uploadFile.getFileName() + " set as logo.");
FacesContext.getCurrentInstance().addMessage(null, msg);
return true;
} catch (IOException e) {
logger.error("{}", e);
return false;
}
}
`
Problem:: My problem is when i am uploading the logo for TEST client the realPath i am getting is "C:\Users\narendra\tls_workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\iclock\clientImage\TEST"
where the realPath supposed to be "src/main/webapp/clientImage/TEST/test.jpeg" and logo should be store into TEST directory,but logo is even not comminng into that directory