Spring 3.0将文件上传至服务器

来源:互联网 发布:小浣熊视频软件 编辑:程序博客网 时间:2024/06/06 03:53
              // file 通过spring注解获取              String imageName = file.getOriginalFilename();              // 获取服务器目录                String localServerPath = request.getSession().getServletContext().getRealPath("/");                // 将文件先存至本地                FileUtils.copyInputStreamToFile(file.getInputStream(), new File(localServerPath, imageName)); 



 

原创粉丝点击