Include this in web.xml
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="1024000000" /> <property name="maxInMemorySize" value="1024000000" /> </bean>
In Jsp
<form:form method="post" autocomplete="off" enctype="multipart/form-data"> </form:form>
In controller
MultipartRequest multipartRequest = (MultipartRequest) request; Map map = multipartRequest.getFileMap(); for (Iterator iter = map.values().iterator(); iter.hasNext();) { MultipartFile mfile = (MultipartFile) iter.next(); if(!mfile.getOriginalFilename().equalsIgnoreCase("")) { StringBuffer isExistA = new StringBuffer(); InputStream is = new ByteArrayInputStream(mfile.getBytes()); String outputLocation = bwtPropertyHandler.getPropertyValue("outputDirectory"); String OutputDir = outputLocation+"PrimaryKeyID"; File f= new File(OutputDir); String attFilesize = String.valueOf(mfile.getSize()); fileSizeTp = Double.valueOf(attFilesize).doubleValue(); if(!(mfile.getSize() == 0)) { f.mkdir(); String outPutLocation = OutputDir +"/" + mfile.getOriginalFilename(); java.io.OutputStream fso = new FileOutputStream(outPutLocation); FileCopyUtils.copy(is, fso); } else { system.out.print("File does not contain any data"); } } }