This is written in my validate method. The check for size and empty upload is working but content type is not, am i missing something ?
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(file1.getFileSize()==0)
{
errors.add("file1", new ActionMessage("error.file.required"));
}
else if(!file1.getContentType().equals("audio/mpeg"));
{
errors.add("file1",new ActionMessage("error.file.type"));
}
if(file1.getFileSize()>51200)
{
errors.add("file1",new ActionMessage("error.file.size"));
}
return errors;
I think your else if condition statement is missing because of ";" sign as the following :
else if(!file1.getContentType().equals("audio/mpeg"));
It should be as the following :
else if(!file1.getContentType().equals("audio/mpeg"))