首页>代码>SWF upload文件批量上传实例>/SWFupload_webwork2.2.6/src/com/whisky/swfupload/action/UploadFilesAction.java
package com.whisky.swfupload.action; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import com.opensymphony.webwork.ServletActionContext; import com.opensymphony.xwork.ActionSupport; public class UploadFilesAction extends ActionSupport { private File attachment; private String attachmentContentType; private String attachmentFileName; @Override public String execute() throws Exception { System.out.println(attachmentContentType); System.out.println(attachmentFileName); System.out.println(">>>>>PATH:" + attachment.getAbsolutePath());// 这里是临时路径,并非原文件路径,不知道咋弄? String destinationPath = ServletActionContext.getServletContext().getRealPath("/") + "upload/"; FileOutputStream out = new FileOutputStream(new File(destinationPath + attachmentFileName)); InputStream in = new FileInputStream(attachment); byte[] buffer = new byte[1024]; while (in.read(buffer) != -1) out.write(buffer); out.close(); in.close(); // Enumeration enums = ServletActionContext.getRequest().getParameterNames(); // while (enums.hasMoreElements()) { // String key = enums.nextElement().toString(); // String value = ServletActionContext.getRequest().getParameter(key); // System.out.println(key + ":" + value); // } return SUCCESS; } public File getAttachment() { return attachment; } public void setAttachment(File attachment) { this.attachment = attachment; } public String getAttachmentContentType() { return attachmentContentType; } public void setAttachmentContentType(String attachmentContentType) { this.attachmentContentType = attachmentContentType; } public String getAttachmentFileName() { return attachmentFileName; } public void setAttachmentFileName(String attachmentFileName) { this.attachmentFileName = attachmentFileName; } }
最近下载更多
ssslgf LV1
2023年7月25日
fy0088 LV2
2022年9月25日
lyd19931203 LV21
2020年6月16日
jiqingxings LV4
2020年3月10日
skipple3 LV39
2020年3月3日
fenghuijun LV26
2019年12月12日
officemeng LV2
2019年1月3日
多捞哦 LV1
2018年10月23日
anhuiyi LV1
2018年5月6日
ning4551 LV5
2018年4月25日