springMVC上传文件保存

//录音上传
    @RequestMapping(value="/uploadRepairVoiceMobile")
    public @ResponseBody void uploadRepairVoiceMobile(MultipartFile voice,HttpServletRequest request) throws Exception {
        if (voice!=null && !voice.isEmpty()) {
            //获取用户单位编号
            String webPath=request.getSession().getServletContext().getRealPath("");
            // 获取存储路径
            String path = webPath+"uploadData"+ File.separator + "voice";
            File dir = new File(path);
       //验证文件是否存在
if (!dir.exists()){ dir.mkdirs(); } File videoDir = new File(path + File.separator + voice.getOriginalFilename());
       //保存文件 voice.transferTo(videoDir); } }

 

posted @ 2017-08-30 09:53  風巽千龍  阅读(149)  评论(0)    收藏  举报