I need to save an Image to my Desktop, but i cannot get that Image file, when I save it, I just save nothing, an empty file, I don't know how to get that file from FileItem.
for (FileItem lFileItem: c.emptyIfNull(pImageLogo))
{
long lFileSize = lFileItem.getSize();
String lFileName = lFileItem.getName();
String lExtensionFile = FilenameUtils.getExtension(lFileName);
String lContentType = lFileItem.getContentType();
if (lContentType.startsWith("image/")) {
if (lFileSize < 100 || lFileSize > Integer.valueOf(lLimitFileSize))
{
lShowAlert=c.msg("userReg.alertSizeFileErrorPart1","File size must be smaller than ") + Integer.valueOf(lLimitFileSize)/1000000 + c.msg("userReg.alertSizeFileErrorPart2","MB and greater than 1KB ");
throw new ErrorControl(lShowAlert);
break;
}
if (lFileSize<=0) break;
c.log(this, "file size="+lFileSize+" max allowed="+lLimitFileSize);
File lFile = new File(logoClientsFolder+"logo_"+ lIdClient + "." + lExtensionFile);
if(lFile.createNewFile())
{
System.out.println("File created: " + lFile.getName());
}
} else {
System.out.println("IS NOT AN IMAGE");
}
}
Can you help me please? Thanks!