I am looking for a way to save a file, although I have the logic to capture it, I am saving it with the name of the image, what I would like to do is capture the file and format the name for example
Date_file_name to be avoided if you upload a file that has the same step.
Currently I'm doing it in this way in struts2 I would also like to know how to do it in Spring-MVc:
introducir el código aquí
private File userImage;
private String userImageContentType;
private String userImageFileName;
private HttpServletRequest servletRequest;
@Override
public String execute() throws Exception{
try {
String filePath = servletRequest.getSession().getServletContext().getRealPath("/images/productos");
System.out.println("FilePatch: " + filePath);
System.out.println("Genero: " + genero);
File fileToCreate = new File(filePath, this.userImageFileName);
FileUtils.copyFile(this.userImage, fileToCreate);
nombreimagen = "images/productos/"+userImageFileName;