首页>代码>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日
最近浏览更多
ssslgf  LV1 2023年7月25日
微信网友_6040315240812544  LV8 2022年11月14日
fy0088  LV2 2022年9月25日
我不划水 2022年4月24日
暂无贡献等级
bai620123  LV16 2022年4月16日
zz臧震1234  LV1 2022年3月10日
240598911  LV10 2021年11月9日
rayzhao 2021年10月22日
暂无贡献等级
CoderMars  LV13 2021年9月10日
沫戏回首  LV10 2021年4月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友