---
title: "uplodify 3.2.1 多文件上传组件使用说明"
author: "TRAMP_ZZY"
date: "2014-01-10T11:04:33Z"
tags: []
categories: ["编程语言"]
slug: "uplodify-3-2-1"
draft: false
lastmod: "2014-01-10T14:20:35Z"
id: 2002212
url: "https://tramp-zzy.iteye.com/blog/2002212"
---

\[code="java"] &lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %&gt; &lt;%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %&gt; " rel="stylesheet" type="text/css"/&gt; " rel="stylesheet" type="text/css"/&gt; " rel="stylesheet" type="text/css" /&gt; " rel="stylesheet" type="text/css" /&gt; " rel="stylesheet" type="text/css" /&gt;

- [所在位置:](javascript:void%280%29)
- [学生信息管理](javascript:void%280%29)
- [同步学生照片](javascript:void%280%29)

[上传照片](javascript:$%28'#uploadify'%29.uploadify%28'upload'%29) [取消上传](javascript:$%28'#uploadify'%29.uploadify%28'cancel'%29) [开始上传所有照片](javascript:$%28'#uploadify'%29.uploadify%28'upload','*'%29)  [取消所有上传](javascript:$%28'#uploadify'%29.uploadify%28'cancel','*'%29)

\[/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(".") &gt;= 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]