spring mvc上传例子

 @RequestMapping(params = "method=fileUpload")
	public String fileUpload(@RequestParam("fileName") MultipartFile upfile,ModelMap map,HttpServletRequest request) throws FileNotFoundException,IOException, SQLException{
    	  
	/* 写入固定目录方式   	   
	 * File file = new File("F:\\"+upfile.getOriginalFilename());  
	    	   byte[] bytes =  upfile.getBytes();
	    	   FileOutputStream fos = new FileOutputStream(file);  
	    	   fos.write(bytes);  
	    	   fos.flush();  
	    	   fos.close();  
	    	   return null;*/
    //写入库方式
		       byte[] fileData = upfile.getBytes();
	               SysUploadFile form = new SysUploadFile();
			form.setAccessories(fileData);
			form.setFile_name(upfile.getOriginalFilename());
			sysUploadService.fileUpload(form);
			return "apps/sysupload/success";
	} 

你可能感兴趣的:(spring,mvc,F#)