"layoutEvents.no_files_uploaded", locale));
}
// This code finds the idField and the upload FileItems
FileItem fi = null;
FileItem imageFi = null;
for (int i=0; i < lst.size(); i++) {
fi = lst.get(i);
String fieldName = fi.getFieldName();
String fieldStr = fi.getString();
if (fi.isFormField()) {
formInput.put(fieldName, fieldStr);
request.setAttribute(fieldName, fieldStr);
//Debug.logVerbose("in uploadAndStoreImage, fieldName:" + fieldName + " fieldStr:" + fieldStr, "");
}
if (fieldName.equals(uploadField)) {
imageFi = fi;
//MimeType of upload file
results.put("uploadMimeType", fi.getContentType());
}
}
if (imageFi == null) {
String errMsg = UtilProperties.getMessage(err_resource,
"layoutEvents.image_null", UtilMisc.toMap("imageFi", imageFi), locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
//Debug.logWarning("[DataEvents.uploadImage] imageFi(" + imageFi + ") is null", module);
return null;
}
byte[] imageBytes = imageFi.get();
ByteBuffer byteWrap = ByteBuffer.wrap(imageBytes);
results.put("imageData", byteWrap);
results.put("imageFileName", imageFi.getName());
//Debug.logVerbose("in uploadAndStoreImage, results:" + results, "");
return results;
}