uplodify 3.2.1 多文件上传组件使用说明
[code="java"] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %> " rel="stylesheet" type="text/css"/> " rel="stylesheet" type="text/css"/> " rel="stylesheet" type="text/css" /> " rel="stylesheet" type="text/css" /> " rel="stylesheet" type="text/css" />
- 所在位置:
- 学生信息管理
- 同步学生照片
上传照片 取消上传 开始上传所有照片 取消所有上传
[/code] [code="java"] @RequestMapping(value = "/importStuPictures.html") public void importStuPicture(HttpServletRequest request, HttpServletResponse response) { String photo_path = PhotoUtils.getPhotoPath(); String photo_upload_path = PhotoUtils.getUploadPhotoPath(); //logger.info(photo_upload_path); DiskFileItemFactory fac = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(fac); upload.setHeaderEncoding("utf-8"); List fileList = null; try { fileList = upload.parseRequest(request); } catch (FileUploadException ex) { logger.info("FileUploadException"); return; } Iterator it = fileList.iterator(); String name = ""; String stuID = ""; while (it.hasNext()) { FileItem item = it.next(); if (!item.isFormField()) { name = item.getName(); if (!StringUtils.isEmpty(name)) { // 扩展名格式: if (name.lastIndexOf(".") >= 0) { stuID = name.substring(0, name.lastIndexOf(".")); if (isExistStudentID(stuID)) { logger.info("stuID " + stuID); // File file = new File(photo_upload_path + name); //if (file.exists()) { // return; // } File saveFile = new File(photo_upload_path + name); try { item.write(saveFile); this.studentService.UpdateStudentPhoto(stuID, photo_path + name); response.getWriter().write("true"); } catch (Exception e) { logger.info("save photo error."); e.printStackTrace(); try { response.getWriter().write("false"); } catch (IOException e1) { e1.printStackTrace(); } } } } } } } } [/code]