uploadify_java.doc

上传人:sk****8 文档编号:3502159 上传时间:2019-06-01 格式:DOC 页数:5 大小:28KB
下载 相关 举报
uploadify_java.doc_第1页
第1页 / 共5页
uploadify_java.doc_第2页
第2页 / 共5页
uploadify_java.doc_第3页
第3页 / 共5页
uploadify_java.doc_第4页
第4页 / 共5页
uploadify_java.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、1. jsp 的内容“ 兑换卷查询系统 提货券类型108138开始上传$(function() var typeCode =“; $(“#file_upload“).uploadify(buttonText : 选择文件,multi : false,swf : html/uploadify.swf,uploader : ./servlet/Upload,auto : false,onUploadStart : function(file) /校验 $(“:inputname=typeCode“).each(function() if ( $(this).attr(“checked“)typeC

2、ode = ($(this).val(););$(“#file_upload“).uploadify(“settings“, “formData“, typeCode:typeCode);););取消所有上传2.java 服务器端的程序package com.alcor.inquire.servlet;import java.io.File;import java.io.IOException;import java.util.Iterator;import java.util.List;import java.util.UUID;import javax.servlet.ServletExc

3、eption;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.log4j.Logger;import org.apache.tomcat.util.http.fileupload.FileItem;import org.apache.tomcat.util.http.fileupload.FileUploadException;import org.a

4、pache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;public class ImportData extends HttpServlet /* */private static final long serialVersionUID = 3387249060639006401L;private static final Logger logger = Logger.getLogger(

5、ImportData.class);public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException logger.debug(“doGet(HttpServletRequest request, HttpServletResponse response)“);String typeCode =“; /兑换卷类型String savePath = this.getServletConfig().getServletContext().ge

6、tRealPath(“);savePath = savePath + “/uploads/“;File f1 = new File(savePath);System.out.println(savePath);if (!f1.exists() f1.mkdirs();DiskFileItemFactory fac = new DiskFileItemFactory();ServletFileUpload upload = new ServletFileUpload(fac);upload.setHeaderEncoding(“utf-8“);List fileList = null;try f

7、ileList = upload.parseRequest(request); catch (FileUploadException ex) return;Iterator it = fileList.iterator();String name = “;String extName = “;while (it.hasNext() FileItem item = it.next();logger.debug(item.getContentType();if (!item.isFormField() name = item.getName();long size = item.getSize()

8、;String type = item.getContentType();logger.debug(“文件名:“+name+“, 大小: “+size + “,类型:“ + type);if (name = null | name.trim().equals(“) continue;/扩展名格式: if (name.lastIndexOf(“.“) = 0) extName = name.substring(name.lastIndexOf(“.“);File file = null;do /生成文件名:name = UUID.randomUUID().toString();file = ne

9、w File(savePath + name + extName); while (file.exists();File saveFile = new File(savePath + name + extName);try item.write(saveFile); catch (Exception e) e.printStackTrace();else/获得简单域的名字 String fieldName = item.getFieldName(); if (fieldName.equalsIgnoreCase(“typeCode“)/获得简单域的值 String fieldValue = i

10、tem.getString(“UTF-8“); typeCode = fieldValue;logger.debug(“兑换卷类型是:“+typeCode);response.getWriter().print(name + extName);/ Process the HTTP Post requestpublic void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doGet(request, response);3.jsp 代码中 如下代码是关键,否则服务端无法获取radio 的值$(“#file_upload“).uploadify(“settings“, “formData“, typeCode:typeCode);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。