I have uploaded my maven/spring project on jelastic and using following to save images:
ServletContext servletContext = request.getSession().getServletContext();
String absoluteFilesystemPath = servletContext.getRealPath("/");
byte[] fileData = file.getBytes();
String name=Trader.getImage();
if (fileData.length != 0) {
String fileName =login.getUserName()+".jpeg";
File f = new File(absoluteFilesystemPath+"\\img\\"+fileName);
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
fileOutputStream.write(fileData);
fileOutputStream.close();
}
It is working on localhost images are saved in img folder while on server it is saved on absolute path as name "img/xyz.jpeg"
i want to save it on
myproject/img/
It is saving on
myproject